Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,10 +1,19 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from huggingface_hub import InferenceApi
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
-
api_token = "your_huggingface_api_token"
|
| 5 |
client = InferenceApi("HuggingFaceM4/idefics2-8b")
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
def model_inference(image, text):
|
|
|
|
| 8 |
inputs = {
|
| 9 |
"inputs": {
|
| 10 |
"text": text,
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from huggingface_hub import InferenceApi
|
| 3 |
+
import base64
|
| 4 |
+
from PIL import Image
|
| 5 |
+
import io
|
| 6 |
|
|
|
|
| 7 |
client = InferenceApi("HuggingFaceM4/idefics2-8b")
|
| 8 |
|
| 9 |
+
def image_to_base64(image):
|
| 10 |
+
buffered = io.BytesIO()
|
| 11 |
+
image.save(buffered, format="JPEG")
|
| 12 |
+
img_str = base64.b64encode(buffered.getvalue()).decode('utf-8')
|
| 13 |
+
return img_str
|
| 14 |
+
|
| 15 |
def model_inference(image, text):
|
| 16 |
+
image_base64 = image_to_base64(image)
|
| 17 |
inputs = {
|
| 18 |
"inputs": {
|
| 19 |
"text": text,
|