Spaces:
Sleeping
Sleeping
alexandrosthegreat
commited on
Commit
•
88fea96
1
Parent(s):
88da15f
Finish
Browse files- app.py +12 -3
- flagged/log.csv +2 -0
- requirements.txt +6 -0
app.py
CHANGED
@@ -3,8 +3,17 @@ import requests
|
|
3 |
import gradio as gr
|
4 |
|
5 |
from transformers import BlipProcessor, BlipForConditionalGeneration
|
6 |
-
def greet(name):
|
7 |
-
return "Hello " + name + "!!"
|
8 |
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
iface.launch()
|
|
|
3 |
import gradio as gr
|
4 |
|
5 |
from transformers import BlipProcessor, BlipForConditionalGeneration
|
|
|
|
|
6 |
|
7 |
+
model_id = "Salesforce/blip-image-captioning-base"
|
8 |
+
|
9 |
+
model = BlipForConditionalGeneration.from_pretrained(model_id)
|
10 |
+
processor = BlipProcessor.from_pretrained(model_id)
|
11 |
+
|
12 |
+
def launch(input):
|
13 |
+
image = Image.open(requests.get(input, stream=True).raw).convert('RGB')
|
14 |
+
inputs = processor(image, return_tensors="pt")
|
15 |
+
out = model.generate(**inputs)
|
16 |
+
return processor.decode(out[0], skip_special_tokens=True)
|
17 |
+
|
18 |
+
iface = gr.Interface(launch, inputs="text", outputs="text")
|
19 |
iface.launch()
|
flagged/log.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
name,output,flag,username,timestamp
|
2 |
+
,Hello !!,,,2023-08-18 15:35:35.677237
|
requirements.txt
CHANGED
@@ -35,7 +35,9 @@ MarkupSafe==2.1.3
|
|
35 |
matplotlib==3.7.2
|
36 |
mdit-py-plugins==0.3.3
|
37 |
mdurl==0.1.2
|
|
|
38 |
multidict==6.0.4
|
|
|
39 |
numpy==1.25.2
|
40 |
orjson==3.9.5
|
41 |
packaging==23.1
|
@@ -58,8 +60,12 @@ semantic-version==2.10.0
|
|
58 |
six==1.16.0
|
59 |
sniffio==1.3.0
|
60 |
starlette==0.27.0
|
|
|
61 |
tokenizers==0.13.3
|
62 |
toolz==0.12.0
|
|
|
|
|
|
|
63 |
tqdm==4.66.1
|
64 |
transformers==4.31.0
|
65 |
typing_extensions==4.7.1
|
|
|
35 |
matplotlib==3.7.2
|
36 |
mdit-py-plugins==0.3.3
|
37 |
mdurl==0.1.2
|
38 |
+
mpmath==1.3.0
|
39 |
multidict==6.0.4
|
40 |
+
networkx==3.1
|
41 |
numpy==1.25.2
|
42 |
orjson==3.9.5
|
43 |
packaging==23.1
|
|
|
60 |
six==1.16.0
|
61 |
sniffio==1.3.0
|
62 |
starlette==0.27.0
|
63 |
+
sympy==1.12
|
64 |
tokenizers==0.13.3
|
65 |
toolz==0.12.0
|
66 |
+
torch==2.0.1
|
67 |
+
torchaudio==2.0.2
|
68 |
+
torchvision==0.15.2
|
69 |
tqdm==4.66.1
|
70 |
transformers==4.31.0
|
71 |
typing_extensions==4.7.1
|