Spaces:
Running
Running
Delete app.py
Browse files
app.py
DELETED
|
@@ -1,94 +0,0 @@
|
|
| 1 |
-
from openai import OpenAI
|
| 2 |
-
import gradio as gr
|
| 3 |
-
from PIL import Image
|
| 4 |
-
import base64
|
| 5 |
-
from io import BytesIO
|
| 6 |
-
import os
|
| 7 |
-
|
| 8 |
-
def identify_vehicle(image):
|
| 9 |
-
try:
|
| 10 |
-
base64_img = image_to_base64(image)
|
| 11 |
-
response = client.chat.completions.create(
|
| 12 |
-
model="gpt-4-vision-preview",
|
| 13 |
-
messages=[
|
| 14 |
-
{
|
| 15 |
-
"role": "user",
|
| 16 |
-
"content": [
|
| 17 |
-
{"type": "text", "text": "Identify the vehicle or part in this photo."},
|
| 18 |
-
{"type": "image_url", "image_url": {"url": f"data:image/jpeg;base64,{base64_img}"}}
|
| 19 |
-
]
|
| 20 |
-
}
|
| 21 |
-
],
|
| 22 |
-
max_tokens=300
|
| 23 |
-
)
|
| 24 |
-
return response.choices[0].message.content
|
| 25 |
-
except Exception as e:
|
| 26 |
-
return f"Error: {e}"
|
| 27 |
-
interface = gr.Interface(
|
| 28 |
-
fn=identify_vehicle,
|
| 29 |
-
inputs=gr.Image(type="pil", label="Upload a car or part photo"),
|
| 30 |
-
outputs="text",
|
| 31 |
-
title="AutoIQ",
|
| 32 |
-
description="Upload a car or part photo. AutoIQ will identify the make, model, year, or visible components."
|
| 33 |
-
)
|
| 34 |
-
|
| 35 |
-
if __name__ == "__main__":
|
| 36 |
-
interface = gr.Interface(
|
| 37 |
-
fn=identify_vehicle,
|
| 38 |
-
inputs=gr.Image(type="pil", label="Upload a car or part photo"),
|
| 39 |
-
outputs="text",
|
| 40 |
-
title="AutoIQ",
|
| 41 |
-
description="Upload a car or part photo. AutoIQ will identify it."
|
| 42 |
-
)
|
| 43 |
-
interface.launch()
|
| 44 |
-
|
| 45 |
-
interface = gr.Interface(
|
| 46 |
-
fn=identify_vehicle,
|
| 47 |
-
inputs=gr.Image(type="pil", label="Upload a car or part photo"),
|
| 48 |
-
outputs="text",
|
| 49 |
-
title="AutoIQ",
|
| 50 |
-
description="Upload a photo of a vehicle or part. AutoIQ will identify what it is."
|
| 51 |
-
)
|
| 52 |
-
|
| 53 |
-
if __name__ == "__main__":
|
| 54 |
-
|
| 55 |
-
interface = gr.Interface(
|
| 56 |
-
fn=identify_vehicle,
|
| 57 |
-
inputs=gr.Image(type="pil", label="Upload a car or part photo"),
|
| 58 |
-
outputs="text",
|
| 59 |
-
title="AutoIQ",
|
| 60 |
-
description="Upload a photo of a vehicle or part. AutoIQ will identify what it is."
|
| 61 |
-
)
|
| 62 |
-
|
| 63 |
-
if __name__ == "__main__":
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
interface = gr.Interface(
|
| 67 |
-
fn=identify_vehicle,
|
| 68 |
-
inputs=gr.Image(type="pil", label="Upload a car or part photo"),
|
| 69 |
-
outputs="text",
|
| 70 |
-
title="AutoIQ",
|
| 71 |
-
description="Upload a photo of a vehicle or part. AutoIQ will identify what it is."
|
| 72 |
-
)
|
| 73 |
-
|
| 74 |
-
if __name__ == "__main__":
|
| 75 |
-
interface = gr.Interface(
|
| 76 |
-
fn=identify_vehicle,
|
| 77 |
-
inputs=gr.Image(type="pil", label="Upload a car or part photo"),
|
| 78 |
-
outputs="text",
|
| 79 |
-
title="AutoIQ",
|
| 80 |
-
description="Upload a car or part photo. AutoIQ will identify it."
|
| 81 |
-
)
|
| 82 |
-
|
| 83 |
-
if __name__ == "__main__":
|
| 84 |
-
interface.launch()
|
| 85 |
-
interface = gr.Interface(
|
| 86 |
-
fn=identify_vehicle,
|
| 87 |
-
inputs=gr.Image(type="pil", label="Upload a car or part photo"),
|
| 88 |
-
outputs="text",
|
| 89 |
-
title="AutoIQ",
|
| 90 |
-
description="Upload a car or part photo. AutoIQ will identify it."
|
| 91 |
-
)
|
| 92 |
-
|
| 93 |
-
if __name__ == "__main__":
|
| 94 |
-
interface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|