Update app.py
Browse files
app.py
CHANGED
@@ -110,11 +110,11 @@ def generate_caption_and_image(image, f, p, d):
|
|
110 |
# return generated_image, generated_image1
|
111 |
messages = [{"role": "user", "content": [{"type": "image"},{"type": "text", "text": "If I had to write a haiku for this one, it would be: "}]}]
|
112 |
input_text = processor.apply_chat_template(messages, add_generation_prompt=True)
|
113 |
-
inputs = processor(
|
114 |
|
115 |
output = model.generate(**inputs, max_new_tokens=30)
|
116 |
caption =processor.decode(output[0])
|
117 |
-
image = pipe(
|
118 |
return image
|
119 |
return None
|
120 |
# Gradio UI
|
|
|
110 |
# return generated_image, generated_image1
|
111 |
messages = [{"role": "user", "content": [{"type": "image"},{"type": "text", "text": "If I had to write a haiku for this one, it would be: "}]}]
|
112 |
input_text = processor.apply_chat_template(messages, add_generation_prompt=True)
|
113 |
+
inputs = processor(img,input_text,add_special_tokens=False,return_tensors="pt").to(device)
|
114 |
|
115 |
output = model.generate(**inputs, max_new_tokens=30)
|
116 |
caption =processor.decode(output[0])
|
117 |
+
image = pipe(caption,height=1024,width=1024,guidance_scale=3.5,num_inference_steps=50,max_sequence_length=512,generator=torch.Generator("cpu").manual_seed(0)).images[0]
|
118 |
return image
|
119 |
return None
|
120 |
# Gradio UI
|