Spaces:
Runtime error
Runtime error
Suggestion to simplify
#2
by
multimodalart HF Staff - opened
- .gitattributes +2 -0
- 0_6as5rHi0sgG4W2Tq.png +3 -0
- 1_sTXgMwDUW0pk-1yK4iHYFw.png +3 -0
- app.py +15 -19
- cute-photos-of-cats-in-grass-1593184777.jpg +0 -0
- inZdRVn7eafZNvaVre2iW1a538.webp +0 -0
- zoomout_2-1440x807.jpg +0 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
0_6as5rHi0sgG4W2Tq.png filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
1_sTXgMwDUW0pk-1yK4iHYFw.png filter=lfs diff=lfs merge=lfs -text
|
0_6as5rHi0sgG4W2Tq.png
ADDED
|
Git LFS Details
|
1_sTXgMwDUW0pk-1yK4iHYFw.png
ADDED
|
Git LFS Details
|
app.py
CHANGED
|
@@ -14,39 +14,35 @@ processor = AutoProcessor.from_pretrained(config.base_model_name_or_path)
|
|
| 14 |
model = model.to(device)
|
| 15 |
model.eval()
|
| 16 |
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
| 22 |
prompts = [[image, prompt]]
|
| 23 |
inputs = processor(prompts[0], return_tensors="pt").to(device)
|
| 24 |
generated_ids = model.generate(**inputs, max_length=max_length)
|
| 25 |
generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
|
| 30 |
title = "Midjourney-like Image Captioning with IDEFICS"
|
| 31 |
description = "Gradio Demo for generating *Midjourney* like captions (describe functionality) with **IDEFICS**"
|
| 32 |
|
| 33 |
examples = [
|
| 34 |
-
["
|
| 35 |
-
["
|
| 36 |
-
["
|
| 37 |
-
["
|
| 38 |
-
["
|
| 39 |
-
|
| 40 |
]
|
| 41 |
io = gr.Interface(fn=predict,
|
| 42 |
inputs=[
|
| 43 |
-
gr.
|
| 44 |
-
gr.Textbox(label="image URL", placeholder="Insert the URL of the image to be described"),
|
| 45 |
-
gr.Image(label="or upload an image", type="pil"),
|
| 46 |
-
gr.Slider(label="Max tokens", value=64, max=128, min=16, step=8)
|
| 47 |
],
|
| 48 |
outputs=[
|
| 49 |
-
gr.Image(type='pil', label="Image"),
|
| 50 |
gr.Textbox(label="IDEFICS Description")
|
| 51 |
],
|
| 52 |
title=title, description=description, examples=examples,
|
|
|
|
| 14 |
model = model.to(device)
|
| 15 |
model.eval()
|
| 16 |
|
| 17 |
+
#Pre-determined best prompt for this fine-tune
|
| 18 |
+
prompt="Describe the following image:"
|
| 19 |
+
|
| 20 |
+
#Max generated tokens for your prompt
|
| 21 |
+
max_length=64
|
| 22 |
+
|
| 23 |
+
def predict(image):
|
| 24 |
prompts = [[image, prompt]]
|
| 25 |
inputs = processor(prompts[0], return_tensors="pt").to(device)
|
| 26 |
generated_ids = model.generate(**inputs, max_length=max_length)
|
| 27 |
generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
| 28 |
+
generated_text = generated_text.replace(prompt,"")
|
| 29 |
+
return generated_text
|
|
|
|
| 30 |
|
| 31 |
title = "Midjourney-like Image Captioning with IDEFICS"
|
| 32 |
description = "Gradio Demo for generating *Midjourney* like captions (describe functionality) with **IDEFICS**"
|
| 33 |
|
| 34 |
examples = [
|
| 35 |
+
["1_sTXgMwDUW0pk-1yK4iHYFw.png"],
|
| 36 |
+
["0_6as5rHi0sgG4W2Tq.png"],
|
| 37 |
+
["zoomout_2-1440x807.jpg"],
|
| 38 |
+
["inZdRVn7eafZNvaVre2iW1a538.webp"],
|
| 39 |
+
["cute-photos-of-cats-in-grass-1593184777.jpg"]
|
|
|
|
| 40 |
]
|
| 41 |
io = gr.Interface(fn=predict,
|
| 42 |
inputs=[
|
| 43 |
+
gr.Image(label="Upload an image", type="pil"),
|
|
|
|
|
|
|
|
|
|
| 44 |
],
|
| 45 |
outputs=[
|
|
|
|
| 46 |
gr.Textbox(label="IDEFICS Description")
|
| 47 |
],
|
| 48 |
title=title, description=description, examples=examples,
|
cute-photos-of-cats-in-grass-1593184777.jpg
ADDED
|
inZdRVn7eafZNvaVre2iW1a538.webp
ADDED
|
zoomout_2-1440x807.jpg
ADDED
|