Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -23,9 +23,13 @@ def greet(image, prompt):
|
|
23 |
|
24 |
|
25 |
# # model = PeftModel(base_model, "/folders").to(device)
|
26 |
-
|
27 |
-
|
28 |
-
|
|
|
|
|
|
|
|
|
29 |
|
30 |
demo = gr.Interface(fn=greet, inputs=[gr.Image(label="Upload image", sources=['upload', 'webcam'], type="pil"), gr.Text()], outputs="text")
|
31 |
demo.launch(share=True)
|
|
|
23 |
|
24 |
|
25 |
# # model = PeftModel(base_model, "/folders").to(device)
|
26 |
+
model_inputs = processor(text=prompt, images=image, return_tensors="pt")
|
27 |
+
input_len = model_inputs["input_ids"].shape[-1]
|
28 |
+
with torch.inference_mode():
|
29 |
+
generation = model.generate(**model_inputs, max_new_tokens=100, do_sample=False)
|
30 |
+
generation = generation[0][input_len:]
|
31 |
+
decoded = processor.decode(generation, skip_special_tokens=True)
|
32 |
+
return decoded
|
33 |
|
34 |
demo = gr.Interface(fn=greet, inputs=[gr.Image(label="Upload image", sources=['upload', 'webcam'], type="pil"), gr.Text()], outputs="text")
|
35 |
demo.launch(share=True)
|