NKASG commited on
Commit
f0ac2cb
·
verified ·
1 Parent(s): b92d030

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -12
app.py CHANGED
@@ -1,13 +1,17 @@
1
- import cohere
2
- import os
3
- from dotenv import load_dotenv
4
- load_dotenv()
5
- COHERE_API_KEY = os.getenv('COHERE_API_KEY')
6
- # OPENAI_API_KEY = os.getenv('OPENAI_API_KEY')
7
- co = cohere.Client(os.environ["COHERE_API_KEY"])
8
 
9
- response = co.generate(
10
- prompt='Please briefly explain to me how Deep Learning works on hardware devices using at most 100 words.',
11
- max_tokens=200
12
- )
13
- print(response.generations[0].text)
 
 
 
 
 
 
 
 
 
1
+ inception_net = tf.keras.applications.MobileNetV2()
2
+ response = requests.get("https://git.io/JJkYN")
3
+ labels = response.text.split("\n")
 
 
 
 
4
 
5
+ def classify_image(inp):
6
+ inp = inp.reshape((-1, 224, 224, 3))
7
+ inp = tf.keras.applications.mobilenet_v2.preprocess_input(inp)
8
+ prediction = inception_net.predict(inp).flatten()
9
+ confidences = {labels[i]: float(prediction[i]) for i in range(1000)}
10
+ return confidences
11
+
12
+ demo = gr.Interface(fn=classify_image,
13
+ inputs=gr.Image(shape=(224, 224)),
14
+ outputs=gr.Label(num_top_classes=3),
15
+ )
16
+
17
+ demo.launch()