Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -69,28 +69,24 @@ def generate_art(mood):
|
|
69 |
return image
|
70 |
|
71 |
def mood_art_generator(image):
|
72 |
-
# Convert base64 string to PIL image
|
73 |
image_encoded = image.split(",")[1]
|
74 |
-
|
75 |
-
|
76 |
-
|
|
|
|
|
77 |
if mood:
|
78 |
art = generate_art(mood)
|
79 |
return art
|
80 |
else:
|
81 |
return None
|
82 |
|
83 |
-
image_input = gr.inputs.Image(shape=(224, 224))
|
84 |
-
outputs = gr.outputs.Image(type
|
85 |
|
86 |
interface = gr.Interface(
|
87 |
fn=mood_art_generator,
|
88 |
inputs=image_input,
|
89 |
outputs=outputs,
|
90 |
title="Mood-based Art Generator",
|
91 |
-
description="Upload an image of yourself and let the AI
|
92 |
-
)
|
93 |
-
|
94 |
-
if __name__ == "__main__":
|
95 |
-
interface.launch()
|
96 |
-
|
|
|
69 |
return image
|
70 |
|
71 |
def mood_art_generator(image):
|
|
|
72 |
image_encoded = image.split(",")[1]
|
73 |
+
# Decode the base64 encoded image
|
74 |
+
image_decoded = base64.b64decode(image_encoded)
|
75 |
+
# Convert the image to a PIL Image
|
76 |
+
image = Image.open(BytesIO(image_decoded)).convert("RGB")
|
77 |
+
mood = get_mood_from_image(image)
|
78 |
if mood:
|
79 |
art = generate_art(mood)
|
80 |
return art
|
81 |
else:
|
82 |
return None
|
83 |
|
84 |
+
image_input = gr.inputs.Image(shape=(224, 224), image_mode="RGB", source="upload")
|
85 |
+
outputs = gr.outputs.Image(type="pil", label="Generated Artwork")
|
86 |
|
87 |
interface = gr.Interface(
|
88 |
fn=mood_art_generator,
|
89 |
inputs=image_input,
|
90 |
outputs=outputs,
|
91 |
title="Mood-based Art Generator",
|
92 |
+
description="Upload an image of yourself and let the AI
|
|
|
|
|
|
|
|
|
|