Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,7 +3,6 @@ import requests
|
|
| 3 |
import os
|
| 4 |
import io
|
| 5 |
from PIL import Image
|
| 6 |
-
from gradio_client import Client
|
| 7 |
|
| 8 |
# Get the API token from environment variable
|
| 9 |
API_TOKEN = os.environ.get("HF_API_TOKEN")
|
|
@@ -24,39 +23,19 @@ def generate_image(prompt):
|
|
| 24 |
image_response = requests.post(API_URL, headers=headers, json={"inputs": prompt})
|
| 25 |
image_bytes = image_response.content
|
| 26 |
image = Image.open(io.BytesIO(image_bytes))
|
| 27 |
-
|
| 28 |
-
with st.spinner("Resizing Image..."):
|
| 29 |
-
client_resize = Client("doevent/AnimateLCM-SVD")
|
| 30 |
-
resized_image = client_resize.predict(image, api_name="/resize_image")
|
| 31 |
-
|
| 32 |
-
with st.spinner("Animating Image..."):
|
| 33 |
-
client_animate = Client("doevent/AnimateLCM-SVD")
|
| 34 |
-
result = client_animate.predict(
|
| 35 |
-
resized_image,
|
| 36 |
-
0,
|
| 37 |
-
True,
|
| 38 |
-
1,
|
| 39 |
-
5,
|
| 40 |
-
1,
|
| 41 |
-
1.5,
|
| 42 |
-
576,
|
| 43 |
-
320,
|
| 44 |
-
20,
|
| 45 |
-
api_name="/video"
|
| 46 |
-
)
|
| 47 |
|
| 48 |
-
return
|
| 49 |
|
| 50 |
# Streamlit interface for user inputs and displaying outputs
|
| 51 |
st.title("Morpheus - Dreams Generator")
|
| 52 |
-
st.write("Enter your feelings and moments of the day to generate a summarization along with an AI-generated
|
| 53 |
|
| 54 |
inputs = st.text_area("Enter your emotions, expressions, best and worst moments of the day:", height=200, value="Today was a mix of emotions. I felt happy in the morning but sad in the evening. The best moment was meeting a friend, and the worst was a stressful meeting.")
|
| 55 |
|
| 56 |
-
if st.button("Generate Summary and
|
| 57 |
summary = generate_text_summary(inputs)
|
| 58 |
st.write("Summary:", summary)
|
| 59 |
|
| 60 |
with st.spinner("Generating Image..."):
|
| 61 |
-
|
| 62 |
-
st.
|
|
|
|
| 3 |
import os
|
| 4 |
import io
|
| 5 |
from PIL import Image
|
|
|
|
| 6 |
|
| 7 |
# Get the API token from environment variable
|
| 8 |
API_TOKEN = os.environ.get("HF_API_TOKEN")
|
|
|
|
| 23 |
image_response = requests.post(API_URL, headers=headers, json={"inputs": prompt})
|
| 24 |
image_bytes = image_response.content
|
| 25 |
image = Image.open(io.BytesIO(image_bytes))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
+
return image
|
| 28 |
|
| 29 |
# Streamlit interface for user inputs and displaying outputs
|
| 30 |
st.title("Morpheus - Dreams Generator")
|
| 31 |
+
st.write("Enter your feelings and moments of the day to generate a summarization along with an AI-generated image!")
|
| 32 |
|
| 33 |
inputs = st.text_area("Enter your emotions, expressions, best and worst moments of the day:", height=200, value="Today was a mix of emotions. I felt happy in the morning but sad in the evening. The best moment was meeting a friend, and the worst was a stressful meeting.")
|
| 34 |
|
| 35 |
+
if st.button("Generate Summary and Image"):
|
| 36 |
summary = generate_text_summary(inputs)
|
| 37 |
st.write("Summary:", summary)
|
| 38 |
|
| 39 |
with st.spinner("Generating Image..."):
|
| 40 |
+
image = generate_image(inputs)
|
| 41 |
+
st.image(image, caption="Generated Image", use_column_width=True)
|