Spaces:
Sleeping
Sleeping
initialize
Browse files- app.py +16 -0
- requirements.txt +1 -0
app.py
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import open_clip
|
3 |
+
|
4 |
+
|
5 |
+
model, _, transform = open_clip.create_model_and_transforms(
|
6 |
+
"coca_ViT-B-32",
|
7 |
+
pretrained="laion2B-s13B-b90k"
|
8 |
+
)
|
9 |
+
|
10 |
+
def output_generate(image):
|
11 |
+
im = transform(image).unsqueeze(0)
|
12 |
+
generated = model.generate(im)
|
13 |
+
return open_clip.decode(generated).split("<end_of_text>")[0].replace("<start_of_text>", "")
|
14 |
+
|
15 |
+
iface = gr.Interface(fn=output_generate, inputs=gr.image(type="pil"), outputs="text")
|
16 |
+
iface.launch()
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
open_clip_torch
|