slimshadow commited on
Commit
db60992
·
verified ·
1 Parent(s): 156e1d4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +44 -28
app.py CHANGED
@@ -1,28 +1,44 @@
1
- import streamlit as st
2
- from gradio_client import Client
3
-
4
- def main():
5
- st.title("Juggernaut-X-v10 Prediction")
6
-
7
- # User input for the prompt
8
- user_prompt = st.text_input("Enter your prompt:")
9
-
10
- if st.button("Generate"):
11
- with st.spinner('Generating...'):
12
- # Call the Gradio API
13
- client = Client("Walmart-the-bag/Juggernaut-X-v10")
14
- result = client.predict(
15
- prompt=user_prompt,
16
- negative_prompt="easynegative, worst quality:1.4, bad composition:1.4, (bad anatomy:1.4, badly drawn hands:1.4, mutation, deformed, extra limb, missing limb, mutated limb, extra finger, missing finger), (deformed fingers:1.4, ugly fingers, ugly fingernails, deformed fingernails), watermarks, graphics, pixelation, blurry, artifacts, logo, (badly drawn face, badly drawn eyes, uneven eyes), imperfect proportions",
17
- steps=50,
18
- guidance_scale=7.5,
19
- add_4k_masterpiece=False,
20
- api_name="/predict"
21
- )
22
- # Display the result
23
- st.success("Generated successfully!")
24
- st.write(result)
25
-
26
- if __name__ == "__main__":
27
- main()
28
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from gradio_client import Client
3
+ from PIL import Image
4
+ import requests
5
+ from io import BytesIO
6
+
7
+ def main():
8
+ st.title("Juggernaut-X-v10 Prediction")
9
+
10
+ # User input for the prompt
11
+ user_prompt = st.text_input("Enter your prompt:")
12
+
13
+ if st.button("Generate"):
14
+ with st.spinner('Generating...'):
15
+ # Call the Gradio API
16
+ client = Client("Walmart-the-bag/Juggernaut-X-v10")
17
+ result = client.predict(
18
+ prompt=user_prompt,
19
+ negative_prompt="easynegative, worst quality:1.4, bad composition:1.4, (bad anatomy:1.4, badly drawn hands:1.4, mutation, deformed, extra limb, missing limb, mutated limb, extra finger, missing finger), (deformed fingers:1.4, ugly fingers, ugly fingernails, deformed fingernails), watermarks, graphics, pixelation, blurry, artifacts, logo, (badly drawn face, badly drawn eyes, uneven eyes), imperfect proportions",
20
+ steps=50,
21
+ guidance_scale=7.5,
22
+ add_4k_masterpiece=False,
23
+ api_name="/predict"
24
+ )
25
+
26
+ # Display the result image
27
+ image_path = result['image'] # Adjust according to the actual key in the result dictionary
28
+ if image_path:
29
+ image_url = f"http://localhost:8501{image_path}" # Adjust if needed
30
+ response = requests.get(image_url)
31
+ image = Image.open(BytesIO(response.content))
32
+ st.image(image, caption="Generated Image")
33
+
34
+ # Provide download button
35
+ image_bytes = BytesIO(response.content).getvalue()
36
+ st.download_button(
37
+ label="Download Image",
38
+ data=image_bytes,
39
+ file_name="generated_image.webp",
40
+ mime="image/webp"
41
+ )
42
+
43
+ if __name__ == "__main__":
44
+ main()