Spaces:
Runtime error
Runtime error
Update generate_propmts.py
Browse files- generate_propmts.py +13 -20
generate_propmts.py
CHANGED
@@ -82,24 +82,17 @@ def get_image_from_space(text, sentence_mapping, character_dict, selected_style,
|
|
82 |
bytes: The generated image data in bytes format, or None if the request fails.
|
83 |
"""
|
84 |
image_bytes = None # Initialize image bytes to None for error handling
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
api_name="/predict"
|
95 |
-
)
|
96 |
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
else:
|
102 |
-
st.error("讗讜讬 诇讗 谞讬转谉 诇讬讬爪专 转诪讜谞讛, 讬砖 诇谞住讜转 砖讜讘 讘讛诪砖讱")
|
103 |
-
except Exception as e:
|
104 |
-
print(f"讗讜讬 诇讗 谞讬转谉 诇讬讬爪专 转诪讜谞讛, 讬砖 诇谞住讜转 砖讜讘 讘讛诪砖讱: {e}")
|
105 |
-
return image_bytes
|
|
|
82 |
bytes: The generated image data in bytes format, or None if the request fails.
|
83 |
"""
|
84 |
image_bytes = None # Initialize image bytes to None for error handling
|
85 |
+
# Define the payload with the text prompt
|
86 |
+
prompt,_ = generate_prompt(text, sentence_mapping, character_dict, selected_style)
|
87 |
+
payload = {
|
88 |
+
"inputs": prompt
|
89 |
+
}
|
90 |
+
result = client.predict(
|
91 |
+
prompt=payload,
|
92 |
+
api_name="/predict"
|
93 |
+
)
|
|
|
|
|
94 |
|
95 |
+
# Check if the result is a base64 encoded string
|
96 |
+
if isinstance(result, str):
|
97 |
+
image_bytes = base64.b64decode(result)
|
98 |
+
return image_bytes
|
|
|
|
|
|
|
|
|
|