Spaces:
Sleeping
Sleeping
Commit
·
b9d4425
1
Parent(s):
a113038
Update app.py
Browse files
app.py
CHANGED
@@ -1,22 +1,12 @@
|
|
1 |
from transformers import pipeline
|
2 |
import gradio as gr
|
3 |
-
|
4 |
-
import io
|
5 |
-
import IPython.display
|
6 |
-
from PIL import Image
|
7 |
-
import base64
|
8 |
-
import gradio as gr
|
9 |
|
10 |
get_completion = pipeline("image-to-text",model="Salesforce/blip-image-captioning-base")
|
11 |
|
12 |
-
|
13 |
-
byte_arr = io.BytesIO()
|
14 |
-
pil_image.save(byte_arr, format='PNG')
|
15 |
-
byte_arr = byte_arr.getvalue()
|
16 |
-
return str(base64.b64encode(byte_arr).decode('utf-8'))
|
17 |
|
18 |
def captioner(image):
|
19 |
-
base64_image = image_to_base64_str(image)
|
20 |
result = get_completion(base64_image)
|
21 |
return result[0]['generated_text']
|
22 |
|
|
|
1 |
from transformers import pipeline
|
2 |
import gradio as gr
|
3 |
+
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
get_completion = pipeline("image-to-text",model="Salesforce/blip-image-captioning-base")
|
6 |
|
7 |
+
|
|
|
|
|
|
|
|
|
8 |
|
9 |
def captioner(image):
|
|
|
10 |
result = get_completion(base64_image)
|
11 |
return result[0]['generated_text']
|
12 |
|