Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,3 @@
|
|
1 |
-
|
2 |
import os
|
3 |
import gradio as gr
|
4 |
import torch
|
@@ -13,11 +12,11 @@ DEFAULT_PROMPT = "<image>"
|
|
13 |
|
14 |
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
15 |
|
16 |
-
model = FlamingoModel.from_pretrained('dhansmair/flamingo-
|
17 |
model.to(device)
|
18 |
model.eval()
|
19 |
|
20 |
-
processor = FlamingoProcessor(model.config,
|
21 |
|
22 |
# setup some example images
|
23 |
examples = []
|
@@ -30,10 +29,11 @@ if os.path.isdir(EXAMPLES_DIR):
|
|
30 |
def predict_caption(image, prompt):
|
31 |
assert isinstance(prompt, str)
|
32 |
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
|
|
37 |
|
38 |
if isinstance(caption, list):
|
39 |
caption = caption[0]
|
@@ -46,4 +46,4 @@ iface = gr.Interface(fn=predict_caption,
|
|
46 |
examples=examples,
|
47 |
outputs="text")
|
48 |
|
49 |
-
iface.launch()
|
|
|
|
|
1 |
import os
|
2 |
import gradio as gr
|
3 |
import torch
|
|
|
12 |
|
13 |
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
14 |
|
15 |
+
model = FlamingoModel.from_pretrained('dhansmair/flamingo-mini')
|
16 |
model.to(device)
|
17 |
model.eval()
|
18 |
|
19 |
+
processor = FlamingoProcessor(model.config, device=device)
|
20 |
|
21 |
# setup some example images
|
22 |
examples = []
|
|
|
29 |
def predict_caption(image, prompt):
|
30 |
assert isinstance(prompt, str)
|
31 |
|
32 |
+
caption = model.generate_captions(
|
33 |
+
processor,
|
34 |
+
images=image,
|
35 |
+
prompt=prompt
|
36 |
+
)
|
37 |
|
38 |
if isinstance(caption, list):
|
39 |
caption = caption[0]
|
|
|
46 |
examples=examples,
|
47 |
outputs="text")
|
48 |
|
49 |
+
iface.launch()
|