Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,7 +8,7 @@ import openai
|
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
-
openai.api_key = "
|
| 12 |
reader = Reader(["tr"])
|
| 13 |
|
| 14 |
|
|
@@ -19,12 +19,18 @@ def get_text(input_img):
|
|
| 19 |
|
| 20 |
|
| 21 |
def save_csv(mahalle, il, sokak, apartman):
|
| 22 |
-
adres_full = [mahalle, il, sokak, apartman]
|
| 23 |
|
|
|
|
| 24 |
with open("adress_book.csv", "a", encoding="utf-8") as f:
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
|
| 30 |
def get_json(mahalle, il, sokak, apartman):
|
|
@@ -62,7 +68,8 @@ def openai_response(ocr_input):
|
|
| 62 |
|
| 63 |
|
| 64 |
with gr.Blocks() as demo:
|
| 65 |
-
gr.Markdown("
|
|
|
|
| 66 |
with gr.Row():
|
| 67 |
img_area = gr.Image()
|
| 68 |
ocr_result = gr.Textbox(label="OCR")
|
|
@@ -91,5 +98,5 @@ with gr.Blocks() as demo:
|
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
-
|
| 95 |
-
|
|
|
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
+
openai.api_key = os.getenv("API_KEY")
|
| 12 |
reader = Reader(["tr"])
|
| 13 |
|
| 14 |
|
|
|
|
| 19 |
|
| 20 |
|
| 21 |
def save_csv(mahalle, il, sokak, apartman):
|
|
|
|
| 22 |
|
| 23 |
+
adres_full = f"{mahalle}, {il}, {sokak}, {apartman}"
|
| 24 |
with open("adress_book.csv", "a", encoding="utf-8") as f:
|
| 25 |
+
book = f.read()
|
| 26 |
+
if adres_full not in book:
|
| 27 |
+
with open("adress_book.csv", "a", encoding="utf-8") as f:
|
| 28 |
+
write = csv.writer(f)
|
| 29 |
+
write.writerow(adres_full)
|
| 30 |
+
else:
|
| 31 |
+
adres_full = "Bu adres daha önce raporlanmış."
|
| 32 |
+
|
| 33 |
+
return adres_full
|
| 34 |
|
| 35 |
|
| 36 |
def get_json(mahalle, il, sokak, apartman):
|
|
|
|
| 68 |
|
| 69 |
|
| 70 |
with gr.Blocks() as demo:
|
| 71 |
+
gr.Markdown("# Enkaz Raporlama")
|
| 72 |
+
gr.Markdown("Bu aplikasyonda üzerinde adres olan bir görüntüyü sürükleyip bırakarak konumu afet koordinasyona raporlayabilirsiniz.")
|
| 73 |
with gr.Row():
|
| 74 |
img_area = gr.Image()
|
| 75 |
ocr_result = gr.Textbox(label="OCR")
|
|
|
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
+
|
| 102 |
+
demo.launch()
|