Spaces:
Runtime error
Runtime error
added convert_image function
Browse files
app.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
# Welcome to Team Tonic's MultiMed
|
| 2 |
-
import numpy as np
|
| 3 |
import os
|
|
|
|
|
|
|
| 4 |
import torch
|
| 5 |
import torchaudio
|
| 6 |
import gradio as gr
|
|
@@ -72,6 +73,14 @@ def predict(
|
|
| 72 |
else:
|
| 73 |
return None, text_out
|
| 74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
def process_image_with_openai(image):
|
| 76 |
image_data = convert_image_to_required_format(image)
|
| 77 |
openai_api_key = os.getenv('OPENAI_API_KEY') # Make sure to have this in your .env file
|
|
|
|
| 1 |
# Welcome to Team Tonic's MultiMed
|
|
|
|
| 2 |
import os
|
| 3 |
+
import numpy as np
|
| 4 |
+
import base64
|
| 5 |
import torch
|
| 6 |
import torchaudio
|
| 7 |
import gradio as gr
|
|
|
|
| 73 |
else:
|
| 74 |
return None, text_out
|
| 75 |
|
| 76 |
+
def convert_image_to_required_format(image):
|
| 77 |
+
"""
|
| 78 |
+
convert image from numpy to base64
|
| 79 |
+
"""
|
| 80 |
+
if type(image) == type(np.array([])):
|
| 81 |
+
return base64.b64encode(image).decode('utf-8')
|
| 82 |
+
|
| 83 |
+
|
| 84 |
def process_image_with_openai(image):
|
| 85 |
image_data = convert_image_to_required_format(image)
|
| 86 |
openai_api_key = os.getenv('OPENAI_API_KEY') # Make sure to have this in your .env file
|