Spaces:
Sleeping
Sleeping
Trying to get rid of base64
Browse files
app.py
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
from transformers import pipeline
|
2 |
import gradio as gr
|
3 |
-
import io
|
4 |
import IPython.display
|
5 |
from PIL import Image
|
6 |
import base64
|
7 |
|
8 |
-
get_completion = pipeline("image-to-text",model="
|
9 |
|
10 |
def summarize(input):
|
11 |
output = get_completion(input)
|
@@ -13,15 +13,15 @@ def summarize(input):
|
|
13 |
|
14 |
import gradio as gr
|
15 |
|
16 |
-
def image_to_base64_str(pil_image):
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
|
22 |
def captioner(image):
|
23 |
-
base64_image = image_to_base64_str(image)
|
24 |
-
result = get_completion(
|
25 |
return result[0]['generated_text']
|
26 |
|
27 |
gr.close_all()
|
|
|
1 |
from transformers import pipeline
|
2 |
import gradio as gr
|
3 |
+
# import io
|
4 |
import IPython.display
|
5 |
from PIL import Image
|
6 |
import base64
|
7 |
|
8 |
+
get_completion = pipeline("image-to-text",model="nlpconnect/vit-gpt2-image-captioning")
|
9 |
|
10 |
def summarize(input):
|
11 |
output = get_completion(input)
|
|
|
13 |
|
14 |
import gradio as gr
|
15 |
|
16 |
+
# def image_to_base64_str(pil_image):
|
17 |
+
# byte_arr = io.BytesIO()
|
18 |
+
# pil_image.save(byte_arr, format='PNG')
|
19 |
+
# byte_arr = byte_arr.getvalue()
|
20 |
+
# return str(base64.b64encode(byte_arr).decode('utf-8'))
|
21 |
|
22 |
def captioner(image):
|
23 |
+
# base64_image = image_to_base64_str(image)
|
24 |
+
result = get_completion(image)
|
25 |
return result[0]['generated_text']
|
26 |
|
27 |
gr.close_all()
|