Spaces:
Runtime error
Runtime error
Upload app.py
Browse files
app.py
CHANGED
|
@@ -1,9 +1,18 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import AutoProcessor, BlipForConditionalGeneration
|
| 3 |
|
| 4 |
-
# from transformers import AutoProcessor, AutoTokenizer, AutoImageProcessor, AutoModelForCausalLM, BlipForConditionalGeneration, Blip2ForConditionalGeneration, VisionEncoderDecoderModel
|
| 5 |
import torch
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
blip_processor_large = AutoProcessor.from_pretrained("umm-maybe/image-generator-identifier")
|
| 8 |
blip_model_large = BlipForConditionalGeneration.from_pretrained("umm-maybe/image-generator-identifier")
|
| 9 |
|
|
@@ -29,7 +38,7 @@ def generate_captions(image):
|
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
-
examples = [["
|
| 33 |
|
| 34 |
title = "Generator Identification via Image Captioning"
|
| 35 |
description = "Gradio Demo to illustrate the use of a fine-tuned BLIP image captioning to identify synthetic images. To use it, simply upload your image and click 'submit', or click one of the examples to load them."
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import AutoProcessor, BlipForConditionalGeneration
|
| 3 |
|
|
|
|
| 4 |
import torch
|
| 5 |
|
| 6 |
+
torch.hub.download_url_to_file('https://static01.nytimes.com/newsgraphics/2023-06-08-disinfo-ai-detector/7343d4ca746b7965141e230d94dd4f5f564f2bfb/_assets/elon.jpg', 'elon.png')
|
| 7 |
+
torch.hub.download_url_to_file('https://static01.nytimes.com/newsgraphics/2023-06-08-disinfo-ai-detector/7343d4ca746b7965141e230d94dd4f5f564f2bfb/_assets/pentagon.jpg', 'pentagon.jpg')
|
| 8 |
+
torch.hub.download_url_to_file('https://static01.nytimes.com/newsgraphics/2023-06-08-disinfo-ai-detector/7343d4ca746b7965141e230d94dd4f5f564f2bfb/_assets/split.jpg', 'split.jpg')
|
| 9 |
+
torch.hub.download_url_to_file('https://static01.nytimes.com/newsgraphics/2023-06-08-disinfo-ai-detector/7343d4ca746b7965141e230d94dd4f5f564f2bfb/_assets/horns.jpg', 'horns.jpg')
|
| 10 |
+
torch.hub.download_url_to_file('https://static01.nytimes.com/newsgraphics/2023-06-08-disinfo-ai-detector/7343d4ca746b7965141e230d94dd4f5f564f2bfb/_assets/waves.png', 'waves.jpg')
|
| 11 |
+
torch.hub.download_url_to_file('https://static01.nytimes.com/newsgraphics/2023-06-08-disinfo-ai-detector/7343d4ca746b7965141e230d94dd4f5f564f2bfb/_assets/australia.jpg', 'australia.jpg')
|
| 12 |
+
torch.hub.download_url_to_file('https://static01.nytimes.com/newsgraphics/2023-06-08-disinfo-ai-detector/7343d4ca746b7965141e230d94dd4f5f564f2bfb/_assets/yeti.jpeg', 'yeti.jpg')
|
| 13 |
+
torch.hub.download_url_to_file('https://static01.nytimes.com/newsgraphics/2023-06-08-disinfo-ai-detector/7343d4ca746b7965141e230d94dd4f5f564f2bfb/_assets/pollock.jpg', 'pollock.jpg')
|
| 14 |
+
torch.hub.download_url_to_file('https://static01.nytimes.com/newsgraphics/2023-06-08-disinfo-ai-detector/7343d4ca746b7965141e230d94dd4f5f564f2bfb/_assets/painting.png', 'painting.jpg')
|
| 15 |
+
|
| 16 |
blip_processor_large = AutoProcessor.from_pretrained("umm-maybe/image-generator-identifier")
|
| 17 |
blip_model_large = BlipForConditionalGeneration.from_pretrained("umm-maybe/image-generator-identifier")
|
| 18 |
|
|
|
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
+
examples = [["elon.jpg"], ["pentagon.jpg"], ["split.jpg"], ["horns.jpg"], ["waves.jpg"], ["australia.jpg"], ["yeti.jpg"], ["pollock.jpg"], ["painting.jpg"]]
|
| 42 |
|
| 43 |
title = "Generator Identification via Image Captioning"
|
| 44 |
description = "Gradio Demo to illustrate the use of a fine-tuned BLIP image captioning to identify synthetic images. To use it, simply upload your image and click 'submit', or click one of the examples to load them."
|