Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -11,12 +11,7 @@ model = AutoPipelineForText2Image.from_pretrained("stabilityai/sdxl-turbo")
|
|
11 |
|
12 |
# Helper function to truncate prompt to fit the model's maximum sequence length
|
13 |
def truncate_prompt(prompt, max_length=77):
|
14 |
-
|
15 |
-
if len(tokens) > max_length:
|
16 |
-
return ' '.join(tokens[:max_length])
|
17 |
-
print("len of tokens:", len(tokens))
|
18 |
-
print("len of tokens:", len(prompt))
|
19 |
-
return prompt
|
20 |
|
21 |
def generate_image(text, sentence_mapping, character_dict, selected_style):
|
22 |
try:
|
@@ -28,6 +23,7 @@ def generate_image(text, sentence_mapping, character_dict, selected_style):
|
|
28 |
output = model(prompt=prompt, num_inference_steps=1, guidance_scale=0.0)
|
29 |
print(f"Model output: {output}")
|
30 |
print("len of output:", len(output))
|
|
|
31 |
# Check if the model returned images
|
32 |
if output.images:
|
33 |
image = output.images[0]
|
|
|
11 |
|
12 |
# Helper function to truncate prompt to fit the model's maximum sequence length
|
13 |
def truncate_prompt(prompt, max_length=77):
|
14 |
+
return prompt[:max_length]
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
def generate_image(text, sentence_mapping, character_dict, selected_style):
|
17 |
try:
|
|
|
23 |
output = model(prompt=prompt, num_inference_steps=1, guidance_scale=0.0)
|
24 |
print(f"Model output: {output}")
|
25 |
print("len of output:", len(output))
|
26 |
+
print("output.images:", output.images)
|
27 |
# Check if the model returned images
|
28 |
if output.images:
|
29 |
image = output.images[0]
|