Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -44,7 +44,6 @@ def get_mood_from_image(image: Image.Image):
|
|
44 |
# Select the mood with the highest score
|
45 |
selected_mood = max(filtered_moods, key=filtered_moods.get)
|
46 |
return selected_mood
|
47 |
-
|
48 |
def generate_art(mood):
|
49 |
# Implement art generation logic using the Stable Diffusion API
|
50 |
prompt = f"{mood} generative art"
|
@@ -68,11 +67,8 @@ def generate_art(mood):
|
|
68 |
|
69 |
return image
|
70 |
|
71 |
-
def mood_art_generator(image):
|
72 |
-
|
73 |
-
image_decoded = base64.b64decode(image_encoded)
|
74 |
-
image_bytes = BytesIO(image_decoded)
|
75 |
-
image = Image.open(image_bytes)
|
76 |
|
77 |
mood = get_mood_from_image(image)
|
78 |
if mood:
|
@@ -83,8 +79,8 @@ def mood_art_generator(image):
|
|
83 |
|
84 |
iface = gr.Interface(
|
85 |
fn=mood_art_generator,
|
86 |
-
inputs="
|
87 |
-
outputs=
|
88 |
title="Mood-based Art Generator",
|
89 |
description="Upload an image of yourself and let the AI generate artwork based on your mood.",
|
90 |
allow_flagging=False,
|
@@ -92,4 +88,4 @@ iface = gr.Interface(
|
|
92 |
share=True
|
93 |
)
|
94 |
|
95 |
-
iface.launch()
|
|
|
44 |
# Select the mood with the highest score
|
45 |
selected_mood = max(filtered_moods, key=filtered_moods.get)
|
46 |
return selected_mood
|
|
|
47 |
def generate_art(mood):
|
48 |
# Implement art generation logic using the Stable Diffusion API
|
49 |
prompt = f"{mood} generative art"
|
|
|
67 |
|
68 |
return image
|
69 |
|
70 |
+
def mood_art_generator(image: np.ndarray):
|
71 |
+
image = Image.fromarray((image * 255).astype(np.uint8))
|
|
|
|
|
|
|
72 |
|
73 |
mood = get_mood_from_image(image)
|
74 |
if mood:
|
|
|
79 |
|
80 |
iface = gr.Interface(
|
81 |
fn=mood_art_generator,
|
82 |
+
inputs=gr.inputs.Image(shape=(224, 224), image_mode="RGB", source="upload"),
|
83 |
+
outputs=gr.outputs.Image(),
|
84 |
title="Mood-based Art Generator",
|
85 |
description="Upload an image of yourself and let the AI generate artwork based on your mood.",
|
86 |
allow_flagging=False,
|
|
|
88 |
share=True
|
89 |
)
|
90 |
|
91 |
+
iface.launch()
|