Commit
•
0d579e3
1
Parent(s):
cd357b0
Update app.py
Browse files
app.py
CHANGED
@@ -43,14 +43,13 @@ with open('transformer/tokenizer.pickle', 'rb') as handle:
|
|
43 |
print("Tokenizer loaded successfully")
|
44 |
|
45 |
|
46 |
-
def transformer(
|
47 |
-
|
48 |
-
print(image)
|
49 |
temp_file, temp_file_path = tempfile.mkstemp(suffix=".jpg")
|
50 |
os.close(temp_file)
|
51 |
-
|
52 |
caption = evaluate_single_image(temp_file_path, tokenizer, loaded_transformer)
|
53 |
return caption
|
54 |
|
55 |
-
interface = gr.Interface(fn=transformer, inputs=gr.Image(type="
|
56 |
interface.launch(debug=True)
|
|
|
43 |
print("Tokenizer loaded successfully")
|
44 |
|
45 |
|
46 |
+
def transformer(image_pil):
|
47 |
+
print(image_pil)
|
|
|
48 |
temp_file, temp_file_path = tempfile.mkstemp(suffix=".jpg")
|
49 |
os.close(temp_file)
|
50 |
+
image_pil.save(temp_file_path)
|
51 |
caption = evaluate_single_image(temp_file_path, tokenizer, loaded_transformer)
|
52 |
return caption
|
53 |
|
54 |
+
interface = gr.Interface(fn=transformer, inputs=gr.Image(type="pil"), outputs="text", api_name="predict")
|
55 |
interface.launch(debug=True)
|