sherpal25 commited on
Commit
dfb7e1f
·
1 Parent(s): e21e602

implemented microsoft model and openai model.

Browse files
Files changed (1) hide show
  1. app.py +24 -7
app.py CHANGED
@@ -5,16 +5,33 @@
5
  from transformers import pipeline
6
  import os
7
  import openai
8
-
9
  openai.organization = "org-5Z0c3Uk1VG7t3TsczN6M4FCi"
10
  #openai.api_key = os.getenv("OPENAI_API_KEY")
11
  openai.api_key_path ="./key.txt"
12
- print(openai.api_key)
13
- print(openai.Model.list())
14
-
15
 
16
- pipe = pipeline("image-classification", model="microsoft/resnet-50")
17
- result = pipe("./man-holding-banana.jpeg")
18
- print(result[0]['label'])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
 
 
 
 
 
20
 
 
5
  from transformers import pipeline
6
  import os
7
  import openai
 
8
  openai.organization = "org-5Z0c3Uk1VG7t3TsczN6M4FCi"
9
  #openai.api_key = os.getenv("OPENAI_API_KEY")
10
  openai.api_key_path ="./key.txt"
 
 
 
11
 
12
+ def askGPT(prompt="what can I make with potato?"):
13
+ response = openai.ChatCompletion.create(
14
+ model="gpt-3.5-turbo",
15
+ messages=[
16
+ {
17
+ "role": "system",
18
+ "content":prompt
19
+ },
20
+ {
21
+ "role": "user",
22
+ "content": ""
23
+ } ],
24
+ temperature=1,
25
+ max_tokens=256,
26
+ top_p=1,
27
+ frequency_penalty=0,
28
+ presence_penalty=0
29
+ )
30
+ result = response["choices"][0]["message"]["content"]
31
+ return result
32
 
33
+ def classifyImage(image):
34
+ pipe = pipeline("image-classification", model="microsoft/resnet-50")
35
+ result = pipe(image)
36
+ return result[0]['label']
37