awacke1 commited on
Commit
66b1848
β€’
1 Parent(s): 15d0d7e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +52 -6
app.py CHANGED
@@ -1,8 +1,39 @@
1
  import streamlit as st
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  def handle_prompt_click(prompt_text, key):
4
  st.session_state[f'selected_prompt_{key}'] = prompt_text
5
- st.write(f"Generated prompt for: {prompt_text}")
 
 
 
 
 
 
 
 
 
6
 
7
  def main():
8
  st.title("🎨 Art Prompt Generator")
@@ -19,7 +50,7 @@ def main():
19
  "Christmas Celebrations art": "πŸŽ„",
20
  "Colorful Art": "🎨",
21
  "Crimson art": "πŸ”΄",
22
- "Eyes Art": "πŸ‘οΈ",
23
  "Going out with Style": "πŸ’ƒ",
24
  "Hooded Girl": "πŸ§₯",
25
  "Lips": "πŸ‘„",
@@ -55,13 +86,28 @@ def main():
55
  with col:
56
  if st.button(f"{emoji} {prompt}", key=f"btn_{idx}"):
57
  handle_prompt_click(full_prompt, idx)
58
-
59
- # Display selected prompt if any
60
  st.markdown("---")
61
- st.markdown("### Generated Prompts:")
 
 
 
 
62
  for key in st.session_state:
63
  if key.startswith('selected_prompt_'):
64
- st.write(st.session_state[key])
 
 
 
 
 
 
 
 
 
 
 
65
 
66
  if __name__ == "__main__":
67
  main()
 
1
  import streamlit as st
2
+ from gradio_client import Client
3
+ import time
4
+
5
+ def generate_image(prompt):
6
+ try:
7
+ client = Client("mukaist/Midjourney")
8
+ result = client.predict(
9
+ prompt=prompt,
10
+ negative_prompt="(deformed iris, deformed pupils, semi-realistic, cgi, 3d, render, sketch, cartoon, drawing, anime:1.4), text, close up, cropped, out of frame, worst quality, low quality, jpeg artifacts, ugly, duplicate, morbid, mutilated, extra fingers, mutated hands, poorly drawn hands, poorly drawn face, mutation, deformed, blurry, dehydrated, bad anatomy, bad proportions, extra limbs, cloned face, disfigured, gross proportions, malformed limbs, missing arms, missing legs, extra arms, extra legs, fused fingers, too many fingers, long neck",
11
+ use_negative_prompt=True,
12
+ style="2560 x 1440",
13
+ seed=0,
14
+ width=1024,
15
+ height=1024,
16
+ guidance_scale=6,
17
+ randomize_seed=True,
18
+ api_name="/run"
19
+ )
20
+ return result
21
+ except Exception as e:
22
+ st.error(f"Error generating image: {str(e)}")
23
+ return None
24
 
25
  def handle_prompt_click(prompt_text, key):
26
  st.session_state[f'selected_prompt_{key}'] = prompt_text
27
+
28
+ # Show loading message
29
+ with st.spinner('Generating artwork...'):
30
+ # Generate the image
31
+ result = generate_image(prompt_text)
32
+
33
+ if result:
34
+ # Store the result in session state
35
+ st.session_state[f'generated_image_{key}'] = result
36
+ st.success("Artwork generated successfully!")
37
 
38
  def main():
39
  st.title("🎨 Art Prompt Generator")
 
50
  "Christmas Celebrations art": "πŸŽ„",
51
  "Colorful Art": "🎨",
52
  "Crimson art": "πŸ”΄",
53
+ "Eyes Art": "πŸ‘„",
54
  "Going out with Style": "πŸ’ƒ",
55
  "Hooded Girl": "πŸ§₯",
56
  "Lips": "πŸ‘„",
 
86
  with col:
87
  if st.button(f"{emoji} {prompt}", key=f"btn_{idx}"):
88
  handle_prompt_click(full_prompt, idx)
89
+
90
+ # Display generated images and prompts
91
  st.markdown("---")
92
+ st.markdown("### Generated Artwork:")
93
+
94
+ # Create columns for displaying images and prompts
95
+ display_cols = st.columns(2)
96
+
97
  for key in st.session_state:
98
  if key.startswith('selected_prompt_'):
99
+ idx = key.split('_')[-1]
100
+ image_key = f'generated_image_{idx}'
101
+
102
+ # Display prompt
103
+ with display_cols[0]:
104
+ st.write("Prompt:", st.session_state[key])
105
+
106
+ # Display image if it exists
107
+ if image_key in st.session_state:
108
+ with display_cols[1]:
109
+ # Assuming the result is a path or URL to the image
110
+ st.image(st.session_state[image_key], caption="Generated Artwork", use_column_width=True)
111
 
112
  if __name__ == "__main__":
113
  main()