Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,13 +1,17 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 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 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
)
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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()
|