Spaces:
Sleeping
Sleeping
chips
commited on
Commit
·
716b26d
1
Parent(s):
e29e8c8
more chatgpt fix
Browse files
app.py
CHANGED
|
@@ -172,8 +172,8 @@ async def describe_garment(image: UploadFile = File(...)):
|
|
| 172 |
image_bytes = await image.read()
|
| 173 |
base64_image = base64.b64encode(image_bytes).decode("utf-8")
|
| 174 |
|
| 175 |
-
response =
|
| 176 |
-
model="gpt-4o",
|
| 177 |
messages=[
|
| 178 |
{
|
| 179 |
"role": "user",
|
|
@@ -181,7 +181,9 @@ async def describe_garment(image: UploadFile = File(...)):
|
|
| 181 |
{"type": "text", "text": "Describe this garment or garments to be inserted into the sentence: a man wearing ..... in front of a white background. be detailed but online describe the garmensts, not the rest of the images"},
|
| 182 |
{
|
| 183 |
"type": "image_url",
|
| 184 |
-
"image_url": {
|
|
|
|
|
|
|
| 185 |
}
|
| 186 |
]
|
| 187 |
}
|
|
@@ -189,5 +191,7 @@ async def describe_garment(image: UploadFile = File(...)):
|
|
| 189 |
max_tokens=300
|
| 190 |
)
|
| 191 |
|
| 192 |
-
description
|
| 193 |
-
|
|
|
|
|
|
|
|
|
| 172 |
image_bytes = await image.read()
|
| 173 |
base64_image = base64.b64encode(image_bytes).decode("utf-8")
|
| 174 |
|
| 175 |
+
response = client.chat.completions.create(
|
| 176 |
+
model="gpt-4o",
|
| 177 |
messages=[
|
| 178 |
{
|
| 179 |
"role": "user",
|
|
|
|
| 181 |
{"type": "text", "text": "Describe this garment or garments to be inserted into the sentence: a man wearing ..... in front of a white background. be detailed but online describe the garmensts, not the rest of the images"},
|
| 182 |
{
|
| 183 |
"type": "image_url",
|
| 184 |
+
"image_url": {
|
| 185 |
+
"url": f"data:image/jpeg;base64,{base64_image}"
|
| 186 |
+
}
|
| 187 |
}
|
| 188 |
]
|
| 189 |
}
|
|
|
|
| 191 |
max_tokens=300
|
| 192 |
)
|
| 193 |
|
| 194 |
+
return {"description": response.choices[0].message.content}
|
| 195 |
+
|
| 196 |
+
|
| 197 |
+
|