Spaces:
Running
Running
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import AutoModel, AutoTokenizer, AutoFeatureExtractor
|
3 |
+
from PIL import Image
|
4 |
+
|
5 |
+
# Load Deepseek-vl2-small model and tokenizer
|
6 |
+
model_name = "Deepseek-vl2-small" # Replace with actual model name if available on HF
|
7 |
+
model = AutoModel.from_pretrained(model_name)
|
8 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
9 |
+
feature_extractor = AutoFeatureExtractor.from_pretrained(model_name)
|
10 |
+
|
11 |
+
# Define inference function
|
12 |
+
def process_image_text(image, text):
|
13 |
+
# Process inputs
|
14 |
+
image_input = feature_extractor(images=image, return_tensors="pt")
|
15 |
+
text_input = tokenizer(text, return_tensors="pt")
|
16 |
+
|
17 |
+
# Get model output
|
18 |
+
outputs = model(**text_input, **image_input)
|
19 |
+
|
20 |
+
# Process output (modify based on your model’s task)
|
21 |
+
return "Model processed the inputs successfully!"
|
22 |
+
|
23 |
+
# Create Gradio interface
|
24 |
+
interface = gr.Interface(
|
25 |
+
fn=process_image_text,
|
26 |
+
inputs=[gr.Image(type="pil"), gr.Textbox()],
|
27 |
+
outputs="text",
|
28 |
+
title="Deepseek-vl2-small Demo"
|
29 |
+
)
|
30 |
+
|
31 |
+
# Launch app
|
32 |
+
interface.launch()
|