siranida commited on
Commit
7724858
·
verified ·
1 Parent(s): b90cf5d

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -0
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from gradio_client import Client, file
2
+ import gradio as gr
3
+ import os
4
+ HEADERS = {
5
+ "Authorization": f"Bearer {os.environ['HF_TOKEN']}"
6
+ }
7
+
8
+ client = Client("mariem2024/plantID")
9
+
10
+ def predict(image_path):
11
+ try:
12
+ result = client.predict(
13
+ file(image_path), # Doğru: gradio `filepath` tipini dosya nesnesine dönüştürüyor
14
+ api_name="/predict"
15
+ )
16
+ return result
17
+ except Exception as e:
18
+ return f"Hata oluştu: {str(e)}"
19
+
20
+ demo = gr.Interface(
21
+ fn=predict,
22
+ inputs=gr.Image(type="filepath"),
23
+ outputs="text",
24
+ title="Bitki Tanıma",
25
+ description="Bu arayüz Hugging Face Space üzerinden bitki türünü tahmin eder."
26
+ )
27
+
28
+ demo.launch()