Update app.py
Browse files
app.py
CHANGED
@@ -40,7 +40,7 @@ def truncate_caption_by_tokens(caption, max_tokens=256):
|
|
40 |
print(f"Caption was truncated from {len(tokens)} tokens to {max_tokens} tokens")
|
41 |
return caption
|
42 |
|
43 |
-
@spaces.GPU(duration=
|
44 |
def generate_enhanced_caption(image_caption, text_caption):
|
45 |
"""Generate enhanced caption using the LeX-Enhancer model"""
|
46 |
combined_caption = f"{image_caption}, with the text on it: {text_caption}."
|
@@ -73,11 +73,13 @@ Below is the simple caption of an image with text. Please deduce the detailed de
|
|
73 |
|
74 |
return combined_caption, enhanced_caption
|
75 |
|
76 |
-
@spaces.GPU(duration=
|
77 |
def generate_image(enhanced_caption, seed, num_inference_steps, guidance_scale):
|
78 |
"""Generate image using LeX-Lumina"""
|
79 |
# Truncate the caption if it's too long
|
80 |
enhanced_caption = truncate_caption_by_tokens(enhanced_caption, max_tokens=256)
|
|
|
|
|
81 |
|
82 |
generator = torch.Generator("cpu").manual_seed(seed) if seed != 0 else None
|
83 |
|
@@ -186,4 +188,4 @@ with gr.Blocks() as demo:
|
|
186 |
)
|
187 |
|
188 |
if __name__ == "__main__":
|
189 |
-
demo.
|
|
|
40 |
print(f"Caption was truncated from {len(tokens)} tokens to {max_tokens} tokens")
|
41 |
return caption
|
42 |
|
43 |
+
@spaces.GPU(duration=50)
|
44 |
def generate_enhanced_caption(image_caption, text_caption):
|
45 |
"""Generate enhanced caption using the LeX-Enhancer model"""
|
46 |
combined_caption = f"{image_caption}, with the text on it: {text_caption}."
|
|
|
73 |
|
74 |
return combined_caption, enhanced_caption
|
75 |
|
76 |
+
@spaces.GPU(duration=60)
|
77 |
def generate_image(enhanced_caption, seed, num_inference_steps, guidance_scale):
|
78 |
"""Generate image using LeX-Lumina"""
|
79 |
# Truncate the caption if it's too long
|
80 |
enhanced_caption = truncate_caption_by_tokens(enhanced_caption, max_tokens=256)
|
81 |
+
|
82 |
+
print(f"enhanced caption:\n{enhanced_caption}")
|
83 |
|
84 |
generator = torch.Generator("cpu").manual_seed(seed) if seed != 0 else None
|
85 |
|
|
|
188 |
)
|
189 |
|
190 |
if __name__ == "__main__":
|
191 |
+
demo.launch(debug=True)
|