Spaces:
Runtime error
Runtime error
Update generate_propmts.py
Browse files- generate_propmts.py +0 -26
generate_propmts.py
CHANGED
@@ -70,29 +70,3 @@ def generate_prompt(text, sentence_mapping, character_dict, selected_style):
|
|
70 |
"watermark, username, blurry "
|
71 |
return prompt, negative_prompt
|
72 |
|
73 |
-
def get_image_from_space(text, sentence_mapping, character_dict, selected_style, client):
|
74 |
-
"""
|
75 |
-
Requests an image from a Hugging Face space based on the provided prompt.
|
76 |
-
|
77 |
-
Parameters:
|
78 |
-
- prompt (str): The text prompt for image generation.
|
79 |
-
- negative_prompt (str): Text specifying what to avoid in the image.
|
80 |
-
|
81 |
-
Returns:
|
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
|
|
|
70 |
"watermark, username, blurry "
|
71 |
return prompt, negative_prompt
|
72 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|