Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,7 +4,7 @@ import base64
|
|
| 4 |
import gradio as gr
|
| 5 |
|
| 6 |
from dotenv import load_dotenv
|
| 7 |
-
from openai import
|
| 8 |
|
| 9 |
|
| 10 |
def generate_data_uri(png_file_path):
|
|
@@ -21,7 +21,7 @@ def generate_data_uri(png_file_path):
|
|
| 21 |
return data_uri
|
| 22 |
|
| 23 |
|
| 24 |
-
def decision(png_file_path, client
|
| 25 |
|
| 26 |
image_data = generate_data_uri(png_file_path)
|
| 27 |
|
|
@@ -71,20 +71,19 @@ def decision(png_file_path, client: OpenAI, lmm: str) -> str:
|
|
| 71 |
|
| 72 |
return decision
|
| 73 |
|
| 74 |
-
def predict(image
|
| 75 |
|
| 76 |
-
lmm = "
|
| 77 |
|
| 78 |
-
client =
|
| 79 |
-
|
| 80 |
-
|
|
|
|
| 81 |
)
|
| 82 |
|
| 83 |
verdict = decision(image, client, lmm)
|
| 84 |
return verdict
|
| 85 |
|
| 86 |
-
load_dotenv()
|
| 87 |
-
|
| 88 |
demo = gr.Interface(
|
| 89 |
fn=predict,
|
| 90 |
inputs=gr.Image(type="filepath", label="Upload your image"),
|
|
|
|
| 4 |
import gradio as gr
|
| 5 |
|
| 6 |
from dotenv import load_dotenv
|
| 7 |
+
from openai import AzureOpenAI
|
| 8 |
|
| 9 |
|
| 10 |
def generate_data_uri(png_file_path):
|
|
|
|
| 21 |
return data_uri
|
| 22 |
|
| 23 |
|
| 24 |
+
def decision(png_file_path, client, lmm: str) -> str:
|
| 25 |
|
| 26 |
image_data = generate_data_uri(png_file_path)
|
| 27 |
|
|
|
|
| 71 |
|
| 72 |
return decision
|
| 73 |
|
| 74 |
+
def predict(image):
|
| 75 |
|
| 76 |
+
lmm = "gpt-4o"
|
| 77 |
|
| 78 |
+
client = AzureOpenAI(
|
| 79 |
+
api_key = os.environ["AZURE_OPENAI_KEY"],
|
| 80 |
+
azure_endpoint = os.environ["AZURE_OPENAI_ENDPOINT"],
|
| 81 |
+
api_version = "2024-02-01"
|
| 82 |
)
|
| 83 |
|
| 84 |
verdict = decision(image, client, lmm)
|
| 85 |
return verdict
|
| 86 |
|
|
|
|
|
|
|
| 87 |
demo = gr.Interface(
|
| 88 |
fn=predict,
|
| 89 |
inputs=gr.Image(type="filepath", label="Upload your image"),
|