user-agent commited on
Commit
e09fed0
1 Parent(s): e92071f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -36,7 +36,7 @@ ATTRIBUTES_DICT = attributes_data['attribute_mapping']
36
  def shot(input, category):
37
  subColour,mainColour,score = get_colour(ast.literal_eval(str(input)),category)
38
  common_result = get_predicted_attributes(ast.literal_eval(str(input)),category)
39
- # openai_parsed_response = get_openAI_tags(ast.literal_eval(str(input)))
40
  return {
41
  "colors":{
42
  "main":mainColour,
@@ -44,7 +44,7 @@ def shot(input, category):
44
  "score":round(score*100,2)
45
  },
46
  "attributes":common_result,
47
- # "image_mapping":openai_parsed_response
48
  }
49
 
50
 
@@ -135,7 +135,7 @@ def get_openAI_tags(image_urls):
135
  "content": [
136
  {
137
  "type": "text",
138
- "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."
139
  }
140
  ]
141
  },
@@ -150,7 +150,7 @@ def get_openAI_tags(image_urls):
150
  frequency_penalty=0,
151
  presence_penalty=0
152
  )
153
- response= json.loads(openai_response.choices[0].message.content)
154
  return response
155
 
156
  # Define the Gradio interface with the updated components
 
36
  def shot(input, category):
37
  subColour,mainColour,score = get_colour(ast.literal_eval(str(input)),category)
38
  common_result = get_predicted_attributes(ast.literal_eval(str(input)),category)
39
+ openai_parsed_response = get_openAI_tags(ast.literal_eval(str(input)))
40
  return {
41
  "colors":{
42
  "main":mainColour,
 
44
  "score":round(score*100,2)
45
  },
46
  "attributes":common_result,
47
+ "image_mapping":openai_parsed_response
48
  }
49
 
50
 
 
135
  "content": [
136
  {
137
  "type": "text",
138
+ "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 an unformatted dictionary where the key is a string representation of the url index of the url and the value is the assigned label."
139
  }
140
  ]
141
  },
 
150
  frequency_penalty=0,
151
  presence_penalty=0
152
  )
153
+ response = json.loads(openai_response.choices[0].message.content)
154
  return response
155
 
156
  # Define the Gradio interface with the updated components