Spaces:
Runtime error
Runtime error
Commit
•
23690be
1
Parent(s):
eccb5ee
UI/UX adjustment for data processing part (#10)
Browse files- lint codebase (9f2d1fef6fb1494f4d88f758d319240a3d6dfdfa)
- update layout (4670957d5979600a5ca362106e57a943a975af05)
Co-authored-by: Kutsal Ozkurt <Goodsea@users.noreply.huggingface.co>
- app.py +25 -16
- db_utils.py +3 -1
- openai_api.py +2 -1
app.py
CHANGED
@@ -34,7 +34,7 @@ def save_deta_db(input):
|
|
34 |
|
35 |
|
36 |
def update_component():
|
37 |
-
return gr.update(value="
|
38 |
|
39 |
|
40 |
def clear_textbox(value):
|
@@ -114,33 +114,42 @@ with gr.Blocks() as demo:
|
|
114 |
"Bu uygulamada ekran görüntüsü sürükleyip bırakarak AFAD'a enkaz bildirimi yapabilirsiniz. Mesajı metin olarak da girebilirsiniz, tam adresi ayrıştırıp döndürür. API olarak kullanmak isterseniz sayfanın en altında use via api'ya tıklayın."
|
115 |
)
|
116 |
with gr.Row():
|
117 |
-
|
|
|
|
|
118 |
|
119 |
with gr.Column():
|
120 |
-
text_area = gr.
|
121 |
-
text_area_button = gr.Button(value=
|
|
|
122 |
open_api_text = gr.Textbox(label="Tam Adres")
|
123 |
-
|
124 |
with gr.Column():
|
125 |
with gr.Row():
|
126 |
-
city = gr.Textbox(label="İl", interactive=True)
|
127 |
-
distinct = gr.Textbox(label="İlçe", interactive=True)
|
128 |
with gr.Row():
|
129 |
-
neighbourhood = gr.Textbox(
|
130 |
-
|
|
|
|
|
|
|
|
|
131 |
with gr.Row():
|
132 |
-
tel = gr.Textbox(label="Telefon", interactive=True)
|
133 |
with gr.Row():
|
134 |
-
name_surname = gr.Textbox(
|
135 |
-
|
|
|
|
|
136 |
with gr.Row():
|
137 |
-
no = gr.Textbox(label="Kapı No", interactive=True)
|
138 |
|
139 |
-
|
140 |
get_parsed_address,
|
141 |
inputs=img_area,
|
142 |
outputs=open_api_text,
|
143 |
-
api_name="
|
144 |
)
|
145 |
|
146 |
text_area_button.click(
|
@@ -154,7 +163,7 @@ with gr.Blocks() as demo:
|
|
154 |
)
|
155 |
|
156 |
submit_button = gr.Button(value="Veriyi Birimlere Yolla")
|
157 |
-
|
158 |
done_text = gr.Textbox(label="Done", value="Not Done", visible=False)
|
159 |
submit_button.click(update_component, outputs=done_text)
|
160 |
for txt in [city, distinct, neighbourhood, street, address, tel, name_surname, no]:
|
|
|
34 |
|
35 |
|
36 |
def update_component():
|
37 |
+
return gr.update(value="Gönderildi, teşekkürler.", visible=True)
|
38 |
|
39 |
|
40 |
def clear_textbox(value):
|
|
|
114 |
"Bu uygulamada ekran görüntüsü sürükleyip bırakarak AFAD'a enkaz bildirimi yapabilirsiniz. Mesajı metin olarak da girebilirsiniz, tam adresi ayrıştırıp döndürür. API olarak kullanmak isterseniz sayfanın en altında use via api'ya tıklayın."
|
115 |
)
|
116 |
with gr.Row():
|
117 |
+
with gr.Column():
|
118 |
+
img_area = gr.Image(label="Ekran Görüntüsü yükleyin 👇")
|
119 |
+
img_area_button = gr.Button(value="Görüntüyü İşle", label="Submit")
|
120 |
|
121 |
with gr.Column():
|
122 |
+
text_area = gr.Textbox(label="Metin yükleyin 👇 ", lines=8)
|
123 |
+
text_area_button = gr.Button(value="Metni Yükle", label="Submit")
|
124 |
+
|
125 |
open_api_text = gr.Textbox(label="Tam Adres")
|
126 |
+
|
127 |
with gr.Column():
|
128 |
with gr.Row():
|
129 |
+
city = gr.Textbox(label="İl", interactive=True, show_progress=False)
|
130 |
+
distinct = gr.Textbox(label="İlçe", interactive=True, show_progress=False)
|
131 |
with gr.Row():
|
132 |
+
neighbourhood = gr.Textbox(
|
133 |
+
label="Mahalle", interactive=True, show_progress=False
|
134 |
+
)
|
135 |
+
street = gr.Textbox(
|
136 |
+
label="Sokak/Cadde/Bulvar", interactive=True, show_progress=False
|
137 |
+
)
|
138 |
with gr.Row():
|
139 |
+
tel = gr.Textbox(label="Telefon", interactive=True, show_progress=False)
|
140 |
with gr.Row():
|
141 |
+
name_surname = gr.Textbox(
|
142 |
+
label="İsim Soyisim", interactive=True, show_progress=False
|
143 |
+
)
|
144 |
+
address = gr.Textbox(label="Adres", interactive=True, show_progress=False)
|
145 |
with gr.Row():
|
146 |
+
no = gr.Textbox(label="Kapı No", interactive=True, show_progress=False)
|
147 |
|
148 |
+
img_area_button.click(
|
149 |
get_parsed_address,
|
150 |
inputs=img_area,
|
151 |
outputs=open_api_text,
|
152 |
+
api_name="upload-image",
|
153 |
)
|
154 |
|
155 |
text_area_button.click(
|
|
|
163 |
)
|
164 |
|
165 |
submit_button = gr.Button(value="Veriyi Birimlere Yolla")
|
166 |
+
submit_button.click(save_deta_db, open_api_text)
|
167 |
done_text = gr.Textbox(label="Done", value="Not Done", visible=False)
|
168 |
submit_button.click(update_component, outputs=done_text)
|
169 |
for txt in [city, distinct, neighbourhood, street, address, tel, name_surname, no]:
|
db_utils.py
CHANGED
@@ -6,6 +6,7 @@ deta_key = os.getenv("DETA_KEY")
|
|
6 |
deta = Deta(deta_key)
|
7 |
db = deta.Base("deprem-ocr")
|
8 |
|
|
|
9 |
def get_users_by_city(city_name, limit=10):
|
10 |
|
11 |
user = db.fetch({"city": city_name.capitalize()}, limit=limit).items
|
@@ -31,7 +32,8 @@ def write_db(data_dict):
|
|
31 |
# 3) create and use as many DBs as you want!
|
32 |
users = deta.Base("deprem-ocr")
|
33 |
users.insert(data_dict)
|
34 |
-
print(
|
|
|
35 |
|
36 |
def get_latest_row(last):
|
37 |
all_items = get_all()
|
|
|
6 |
deta = Deta(deta_key)
|
7 |
db = deta.Base("deprem-ocr")
|
8 |
|
9 |
+
|
10 |
def get_users_by_city(city_name, limit=10):
|
11 |
|
12 |
user = db.fetch({"city": city_name.capitalize()}, limit=limit).items
|
|
|
32 |
# 3) create and use as many DBs as you want!
|
33 |
users = deta.Base("deprem-ocr")
|
34 |
users.insert(data_dict)
|
35 |
+
print("Pushed to db")
|
36 |
+
|
37 |
|
38 |
def get_latest_row(last):
|
39 |
all_items = get_all()
|
openai_api.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import openai
|
2 |
import os
|
3 |
|
|
|
4 |
class OpenAI_API:
|
5 |
def __init__(self):
|
6 |
self.openai_api_key = ""
|
@@ -15,7 +16,7 @@ class OpenAI_API:
|
|
15 |
response = openai.Completion.create(
|
16 |
engine="Davinci-003",
|
17 |
prompt=address_text,
|
18 |
-
temperature=0
|
19 |
max_tokens=500,
|
20 |
top_p=1,
|
21 |
# n=1,
|
|
|
1 |
import openai
|
2 |
import os
|
3 |
|
4 |
+
|
5 |
class OpenAI_API:
|
6 |
def __init__(self):
|
7 |
self.openai_api_key = ""
|
|
|
16 |
response = openai.Completion.create(
|
17 |
engine="Davinci-003",
|
18 |
prompt=address_text,
|
19 |
+
temperature=0.0,
|
20 |
max_tokens=500,
|
21 |
top_p=1,
|
22 |
# n=1,
|