user-agent commited on
Commit
ca2d13e
1 Parent(s): 540630a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -1
app.py CHANGED
@@ -113,7 +113,35 @@ def get_predicted_attributes(image_urls, category):
113
  return result
114
 
115
 
116
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
117
 
118
  # Define the Gradio interface with the updated components
119
  iface = gr.Interface(
 
113
  return result
114
 
115
 
116
+ def get_openAI_tags(image_urls):
117
+ # Create list containing JSONs of each image URL
118
+ imageList = []
119
+ for image in image_urls:
120
+ imageList.append({"type": "image_url", "image_url": {"url": image}})
121
+
122
+ return client.chat.completions.create(
123
+ model="gpt-4o",
124
+ messages=[
125
+ {
126
+ "role": "system",
127
+ "content": [
128
+ {
129
+ "type": "text",
130
+ "text": "You're a tagging assistant, you will help label and tag product pictures for my online e-commerce platform. Your tasks will be to return which angle the product images were taken from. You will have to choose from 'full-body', 'half-body', 'side', 'back', or 'zoomed' angles. You should label each of the images with one of these labels depending on which you think fits best (ideally, every label should be used at least once, but only if there are 5 or more images), and should respond with nothing but the labels separated by a comma in the order of the images without any other text. You should label every picture, no more, no less."
131
+ }
132
+ ]
133
+ },
134
+ {
135
+ "role": "user",
136
+ "content": imageList
137
+ },
138
+ ],
139
+ temperature=1,
140
+ max_tokens=500,
141
+ top_p=1,
142
+ frequency_penalty=0,
143
+ presence_penalty=0
144
+ )
145
 
146
  # Define the Gradio interface with the updated components
147
  iface = gr.Interface(