sherpal25 commited on
Commit
1a63bf3
·
1 Parent(s): 4516305

bring the model call in the same space.

Browse files
Files changed (1) hide show
  1. app.py +37 -0
app.py CHANGED
@@ -133,6 +133,43 @@ def capture_image():
133
  cap.release()
134
  return image_path
135
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
136
 
137
  if __name__ == '__main__':
138
  main()
 
133
  cap.release()
134
  return image_path
135
 
136
+ # This is the main logic file that contains hugging face model interaction
137
+
138
+ # This model is for detecting food in the image.
139
+ # Use a pipeline as a high-level helper
140
+ from transformers import pipeline
141
+ import os
142
+ import openai
143
+ openai.organization = "org-5Z0c3Uk1VG7t3TsczN6M4FCi"
144
+ #openai.api_key = os.getenv("OPENAI_API_KEY")
145
+ openai.api_key_path ="./key.txt"
146
+
147
+ def askGPT(prompt="what can I make with potato?"):
148
+ response = openai.ChatCompletion.create(
149
+ model="gpt-3.5-turbo",
150
+ messages=[
151
+ {
152
+ "role": "system",
153
+ "content":prompt
154
+ },
155
+ {
156
+ "role": "user",
157
+ "content": ""
158
+ } ],
159
+ temperature=1,
160
+ max_tokens=256,
161
+ top_p=1,
162
+ frequency_penalty=0,
163
+ presence_penalty=0
164
+ )
165
+ result = response["choices"][0]["message"]["content"]
166
+ return result
167
+
168
+ def classifyImage(image):
169
+ pipe = pipeline("image-classification", model="microsoft/resnet-50")
170
+ result = pipe(image)
171
+ return result[0]['label']
172
+
173
 
174
  if __name__ == '__main__':
175
  main()