roundb commited on
Commit
6eae3f4
·
verified ·
1 Parent(s): 5cb6de5

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +472 -0
  2. requirements.txt +1 -0
app.py ADDED
@@ -0,0 +1,472 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # app_demo.py — DEMO (somente interface Gradio, sem executar IA/processamento)
2
+ # Requisitos: gradio>=4.26.0
3
+ #
4
+ # Este app:
5
+ # - Mantém a mesma ideia das 5 abas (GPX → Frames → Segmentação → Resize → Inferência)
6
+ # - NÃO usa torch/cv2/transformers/pandas/exiftool
7
+ # - Gera arquivos “mock” (GPX/ZIP/CSV/GEOJSON) só para download e para a UI ficar funcional
8
+
9
+ import os
10
+ import json
11
+ import time
12
+ import zipfile
13
+ import tempfile
14
+ from datetime import datetime
15
+ import gradio as gr
16
+
17
+
18
+ STATE = {} # guarda caminhos dos “artefatos” demo
19
+
20
+
21
+ # -------------------------
22
+ # Helpers (gera arquivos falsos)
23
+ # -------------------------
24
+ def _tmpdir(prefix="demo_"):
25
+ return tempfile.mkdtemp(prefix=prefix)
26
+
27
+ def _write_text(path, text, encoding="utf-8"):
28
+ os.makedirs(os.path.dirname(path), exist_ok=True)
29
+ with open(path, "w", encoding=encoding) as f:
30
+ f.write(text)
31
+
32
+ def _create_dummy_gpx(out_path: str, track_name="demo_track"):
33
+ gpx = f"""<?xml version="1.0" encoding="UTF-8"?>
34
+ <gpx version="1.1" creator="DEMO - Gradio" xmlns="http://www.topografix.com/GPX/1/1">
35
+ <metadata>
36
+ <name>{track_name}</name>
37
+ <time>{datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ")}</time>
38
+ </metadata>
39
+ <trk>
40
+ <name>{track_name}</name>
41
+ <trkseg>
42
+ <trkpt lat="38.722252" lon="-9.139337"><time>{datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ")}</time></trkpt>
43
+ <trkpt lat="38.722300" lon="-9.139200"><time>{datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ")}</time></trkpt>
44
+ <trkpt lat="38.722380" lon="-9.139050"><time>{datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ")}</time></trkpt>
45
+ </trkseg>
46
+ </trk>
47
+ </gpx>
48
+ """
49
+ _write_text(out_path, gpx)
50
+
51
+ def _create_dummy_zip(out_path: str, kind="frames"):
52
+ """
53
+ kind:
54
+ - "frames": zip com 3 jpg “fake”
55
+ - "segmentacao": zip com pastas class_6_road, class_11_sidewalk, class_9_grass e jpg “fake”
56
+ - "224": zip com as mesmas pastas, mas “redimensionadas”
57
+ """
58
+ tmp = _tmpdir("demo_zip_")
59
+ if kind == "frames":
60
+ files = ["frame_000000_lat_38.722252_lon_-9.139337.jpg",
61
+ "frame_000030_lat_38.722300_lon_-9.139200.jpg",
62
+ "frame_000060_lat_38.722380_lon_-9.139050.jpg"]
63
+ for name in files:
64
+ _write_text(os.path.join(tmp, name), "DEMO IMAGE BYTES PLACEHOLDER\n")
65
+ else:
66
+ mapping = {
67
+ "class_6_road": ["img_001_class_6_road.jpg", "img_002_class_6_road.jpg"],
68
+ "class_11_sidewalk": ["img_003_class_11_sidewalk.jpg"],
69
+ "class_9_grass": ["img_004_class_9_grass.jpg"],
70
+ }
71
+ for folder, imgs in mapping.items():
72
+ folder_path = os.path.join(tmp, folder)
73
+ os.makedirs(folder_path, exist_ok=True)
74
+ for img in imgs:
75
+ _write_text(os.path.join(folder_path, img), f"DEMO {kind} PLACEHOLDER\n")
76
+
77
+ # incluir um csv fake no zip (no caso de segmentacao/224)
78
+ _write_text(os.path.join(tmp, "resultados_segmentacao.csv"),
79
+ "imagem,classe_id,classe_nome,latitude,longitude,pixels_classe,pixels_totais,proporcao_classe_%\n"
80
+ "img_001_class_6_road.jpg,6,road,38.722252,-9.139337,12345,50176,24.60\n")
81
+
82
+ # zipar
83
+ with zipfile.ZipFile(out_path, "w", zipfile.ZIP_DEFLATED) as zf:
84
+ for root, _, files in os.walk(tmp):
85
+ for f in files:
86
+ full = os.path.join(root, f)
87
+ arc = os.path.relpath(full, tmp)
88
+ zf.write(full, arc)
89
+
90
+ def _create_dummy_csv_and_geojson(out_dir: str, classe: str):
91
+ csv_path = os.path.join(out_dir, f"inferencia_{classe}_vit.csv")
92
+ geojson_path = os.path.join(out_dir, f"inferencia_{classe}_vit.geojson")
93
+
94
+ csv_text = (
95
+ "imagem,classe_predita,confianca,latitude,longitude,timestamp\n"
96
+ f"img_001_{classe}.jpg,{classe},0.91,38.722252,-9.139337,{datetime.utcnow().isoformat()}\n"
97
+ f"img_002_{classe}.jpg,{classe},0.88,38.722300,-9.139200,{datetime.utcnow().isoformat()}\n"
98
+ )
99
+ _write_text(csv_path, csv_text)
100
+
101
+ geo = {
102
+ "type": "FeatureCollection",
103
+ "features": [
104
+ {
105
+ "type": "Feature",
106
+ "geometry": {"type": "Point", "coordinates": [-9.139337, 38.722252]},
107
+ "properties": {"imagem": f"img_001_{classe}.jpg", "classe_predita": classe, "confianca": 0.91}
108
+ },
109
+ {
110
+ "type": "Feature",
111
+ "geometry": {"type": "Point", "coordinates": [-9.139200, 38.722300]},
112
+ "properties": {"imagem": f"img_002_{classe}.jpg", "classe_predita": classe, "confianca": 0.88}
113
+ },
114
+ ],
115
+ }
116
+ _write_text(geojson_path, json.dumps(geo, indent=2, ensure_ascii=False))
117
+
118
+ return csv_path, geojson_path
119
+
120
+
121
+ # -------------------------
122
+ # Aba 1 — DEMO GPX
123
+ # -------------------------
124
+ def aba1_demo_extrair_gpx(video_file, exiftool_path, progress=gr.Progress()):
125
+ logs = []
126
+ def log(msg):
127
+ logs.append(msg)
128
+ progress(0.2, desc=msg)
129
+
130
+ if not video_file:
131
+ log("❌ DEMO: Nenhum vídeo selecionado.")
132
+ return None, "\n".join(logs)
133
+
134
+ # Só para simular
135
+ log("🎬 DEMO: Recebi um vídeo (não será processado).")
136
+ time.sleep(0.2)
137
+ log("🛰️ DEMO: Simulando extração de telemetria...")
138
+ time.sleep(0.2)
139
+
140
+ out_dir = _tmpdir("demo_gpx_")
141
+ base = "demo_video"
142
+ out_gpx = os.path.join(out_dir, f"{base}.gpx")
143
+ _create_dummy_gpx(out_gpx, track_name=base)
144
+
145
+ STATE["gpx_path"] = out_gpx
146
+ log("✅ DEMO: GPX gerado com sucesso (arquivo mock).")
147
+ progress(1.0, desc="Concluído!")
148
+ return out_gpx, "\n".join(logs)
149
+
150
+
151
+ # -------------------------
152
+ # Aba 2 — DEMO Frames ZIP
153
+ # -------------------------
154
+ def aba2_demo_extrair_frames(video_file, gpx_file, frame_interval, progress=gr.Progress()):
155
+ logs = []
156
+ def log(msg):
157
+ logs.append(msg)
158
+
159
+ if not video_file:
160
+ log("❌ DEMO: Nenhum vídeo selecionado.")
161
+ return None, "\n".join(logs)
162
+ if not gpx_file:
163
+ log("❌ DEMO: Nenhum GPX selecionado.")
164
+ return None, "\n".join(logs)
165
+
166
+ progress(0.2, desc="DEMO: Simulando extração de frames...")
167
+ time.sleep(0.2)
168
+
169
+ zip_path = os.path.join(tempfile.gettempdir(), "frames_georreferenciados_DEMO.zip")
170
+ _create_dummy_zip(zip_path, kind="frames")
171
+ STATE["frames_zip"] = zip_path
172
+
173
+ log(f"✅ DEMO: ZIP de frames gerado (mock). Intervalo solicitado: {frame_interval}")
174
+ progress(1.0, desc="Concluído!")
175
+ return zip_path, "\n".join(logs)
176
+
177
+
178
+ # -------------------------
179
+ # Aba 3 — DEMO Segmentação ZIP + CSV
180
+ # -------------------------
181
+ def aba3_demo_segmentacao(zip_file, batch_size, progress=gr.Progress()):
182
+ logs = []
183
+ def log(msg):
184
+ logs.append(msg)
185
+
186
+ if not zip_file:
187
+ log("❌ DEMO: Nenhum ZIP selecionado.")
188
+ return None, None, "\n".join(logs)
189
+
190
+ progress(0.2, desc="DEMO: Carregando modelo (fake)...")
191
+ time.sleep(0.2)
192
+ progress(0.5, desc="DEMO: Segmentando imagens (fake)...")
193
+ time.sleep(0.2)
194
+
195
+ out_dir = _tmpdir("demo_seg_")
196
+ csv_path = os.path.join(out_dir, "resultados_segmentacao.csv")
197
+ _write_text(csv_path,
198
+ "imagem,classe_id,classe_nome,latitude,longitude,pixels_classe,pixels_totais,proporcao_classe_%\n"
199
+ "img_001_class_6_road.jpg,6,road,38.722252,-9.139337,12345,50176,24.60\n"
200
+ "img_003_class_11_sidewalk.jpg,11,sidewalk,38.722300,-9.139200,8000,50176,15.94\n"
201
+ "img_004_class_9_grass.jpg,9,grass,38.722380,-9.139050,6000,50176,11.96\n")
202
+
203
+ zip_output = os.path.join(tempfile.gettempdir(), "segmentacao_classes_DEMO.zip")
204
+ _create_dummy_zip(zip_output, kind="segmentacao")
205
+
206
+ STATE["segmentacao_zip"] = zip_output
207
+ log(f"✅ DEMO: Segmentação concluída (mock). Batch solicitado: {batch_size}")
208
+ progress(1.0, desc="Concluído!")
209
+ return zip_output, csv_path, "\n".join(logs)
210
+
211
+
212
+ # -------------------------
213
+ # Aba 4 — DEMO Resize 224 ZIP + Manifest CSV
214
+ # -------------------------
215
+ def aba4_demo_redimensionar(zip_file, progress=gr.Progress()):
216
+ logs = []
217
+ def log(msg):
218
+ logs.append(msg)
219
+
220
+ if not zip_file:
221
+ log("❌ DEMO: Nenhum ZIP selecionado.")
222
+ return None, None, "\n".join(logs)
223
+
224
+ progress(0.3, desc="DEMO: Redimensionando para 224×224 (fake)...")
225
+ time.sleep(0.2)
226
+
227
+ out_dir = _tmpdir("demo_224_")
228
+ csv_path = os.path.join(out_dir, "manifest_224x224.csv")
229
+ _write_text(csv_path,
230
+ "original_path,output_path,latitude,longitude,size\n"
231
+ "class_6_road/img_001_class_6_road.jpg,class_6_road/img_001_class_6_road.jpg,38.722252,-9.139337,224x224\n"
232
+ "class_11_sidewalk/img_003_class_11_sidewalk.jpg,class_11_sidewalk/img_003_class_11_sidewalk.jpg,38.722300,-9.139200,224x224\n"
233
+ "class_9_grass/img_004_class_9_grass.jpg,class_9_grass/img_004_class_9_grass.jpg,38.722380,-9.139050,224x224\n")
234
+
235
+ zip_output = os.path.join(tempfile.gettempdir(), "segmentacao_224x224_DEMO.zip")
236
+ _create_dummy_zip(zip_output, kind="224")
237
+
238
+ STATE["zip_224"] = zip_output
239
+ log("✅ DEMO: ZIP 224×224 gerado (mock).")
240
+ progress(1.0, desc="Concluído!")
241
+ return zip_output, csv_path, "\n".join(logs)
242
+
243
+
244
+ # -------------------------
245
+ # Aba 5 — DEMO Preparar ZIPs por classe
246
+ # -------------------------
247
+ def aba5_demo_preparar_zips(zip_file_224, progress=gr.Progress()):
248
+ logs = []
249
+ def log(msg):
250
+ logs.append(msg)
251
+
252
+ if not zip_file_224:
253
+ log("❌ DEMO: Nenhum ZIP 224×224 selecionado.")
254
+ return "\n".join(logs), None, None, None, gr.update(choices=[])
255
+
256
+ progress(0.4, desc="DEMO: Preparando ZIPs por classe (fake)...")
257
+ time.sleep(0.2)
258
+
259
+ # Criar 3 zips mock
260
+ zip_paths = {}
261
+ for classe in ("road", "sidewalk", "grass"):
262
+ zp = os.path.join(tempfile.gettempdir(), f"{classe}_224x224_DEMO.zip")
263
+ _create_dummy_zip(zp, kind="224")
264
+ zip_paths[classe] = zp
265
+
266
+ STATE["class_zips"] = zip_paths
267
+
268
+ log("✅ DEMO: ZIPs separados por classe prontos (mock).")
269
+ progress(1.0, desc="Concluído!")
270
+ choices = list(zip_paths.keys())
271
+ return (
272
+ "\n".join(logs),
273
+ zip_paths.get("road"),
274
+ zip_paths.get("sidewalk"),
275
+ zip_paths.get("grass"),
276
+ gr.update(choices=choices, value=choices[0] if choices else None),
277
+ )
278
+
279
+
280
+ # -------------------------
281
+ # Aba 5 — DEMO Inferência (gera CSV + GeoJSON)
282
+ # -------------------------
283
+ def aba5_demo_inferencia(classe_selecionada, model_file, metadata_file, progress=gr.Progress()):
284
+ logs = []
285
+ def log(msg):
286
+ logs.append(msg)
287
+
288
+ if not classe_selecionada:
289
+ log("❌ DEMO: Nenhuma classe selecionada.")
290
+ return None, None, "\n".join(logs)
291
+
292
+ progress(0.3, desc="DEMO: Carregando modelo ViT (fake)...")
293
+ time.sleep(0.2)
294
+ progress(0.6, desc="DEMO: Inferindo (fake)...")
295
+ time.sleep(0.2)
296
+
297
+ out_dir = _tmpdir("demo_infer_")
298
+ csv_path, geojson_path = _create_dummy_csv_and_geojson(out_dir, classe_selecionada)
299
+
300
+ log("✅ DEMO: Inferência concluída (mock).")
301
+ log(f"📄 CSV: {os.path.basename(csv_path)}")
302
+ log(f"🗺️ GeoJSON: {os.path.basename(geojson_path)}")
303
+ progress(1.0, desc="Concluído!")
304
+ return csv_path, geojson_path, "\n".join(logs)
305
+
306
+
307
+ # -------------------------
308
+ # Interface
309
+ # -------------------------
310
+ def create_interface():
311
+ with gr.Blocks(title="Processador de Vídeos (DEMO)", theme=gr.themes.Soft()) as app:
312
+ gr.Markdown(
313
+ """
314
+ # 🗺️ ROUNDB - Processador de Vídeos - IA (DEMO)
315
+
316
+ ✅ **Este é um DEMO de interface.**
317
+ - Não executa IA, não usa ExifTool, não processa vídeo.
318
+ - Os botões geram **arquivos “mock”** para download (GPX/ZIP/CSV/GeoJSON) e logs para demonstrar o fluxo.
319
+
320
+ **Fluxo sugerido:** Aba 1 → 2 → 3 → 4 → 5
321
+ """
322
+ )
323
+
324
+ with gr.Tabs():
325
+ # -------- Aba 1
326
+ with gr.Tab("1️⃣ Extração de GPX (DEMO)"):
327
+ gr.Markdown("## 📍 Extrator de GPX (DEMO)")
328
+ with gr.Row():
329
+ with gr.Column():
330
+ video_input_1 = gr.File(label="📹 Vídeo", file_types=["video"], type="filepath")
331
+ exiftool_input_1 = gr.Textbox(
332
+ label="🔧 Caminho do ExifTool (opcional, DEMO)",
333
+ placeholder="C:/exiftool",
334
+ value="",
335
+ )
336
+ btn1 = gr.Button("🚀 Extrair GPX (DEMO)", variant="primary")
337
+ with gr.Column():
338
+ log1 = gr.Textbox(label="📋 Log", lines=16, interactive=False)
339
+ gpx_out = gr.File(label="📥 Download do GPX (mock)")
340
+
341
+ btn1.click(
342
+ fn=aba1_demo_extrair_gpx,
343
+ inputs=[video_input_1, exiftool_input_1],
344
+ outputs=[gpx_out, log1],
345
+ )
346
+
347
+ # -------- Aba 2
348
+ with gr.Tab("2️⃣ Frames Georreferenciados (DEMO)"):
349
+ gr.Markdown("## 🎬 Extrator de Frames (DEMO)")
350
+ with gr.Row():
351
+ with gr.Column():
352
+ video_input_2 = gr.File(label="📹 Vídeo (mesmo da Aba 1)", file_types=["video"], type="filepath")
353
+ gpx_input_2 = gr.File(label="🗺️ GPX (gerado na Aba 1)", file_types=[".gpx"], type="filepath")
354
+ frame_interval = gr.Slider(1, 300, value=30, step=1, label="📸 Intervalo de Frames (DEMO)")
355
+ btn2 = gr.Button("🚀 Extrair Frames (DEMO)", variant="primary")
356
+ with gr.Column():
357
+ log2 = gr.Textbox(label="📋 Log", lines=16, interactive=False)
358
+ frames_zip = gr.File(label="📥 Download (ZIP frames mock)")
359
+
360
+ gpx_out.change(fn=lambda v, g: (v, g), inputs=[video_input_1, gpx_out], outputs=[video_input_2, gpx_input_2])
361
+
362
+ btn2.click(
363
+ fn=aba2_demo_extrair_frames,
364
+ inputs=[video_input_2, gpx_input_2, frame_interval],
365
+ outputs=[frames_zip, log2],
366
+ )
367
+
368
+ # -------- Aba 3
369
+ with gr.Tab("3️⃣ Segmentação (ADE20K) (DEMO)"):
370
+ gr.Markdown("## 🤖 Segmentação Semântica (DEMO)")
371
+ with gr.Row():
372
+ with gr.Column():
373
+ zip_in_3 = gr.File(label="📦 ZIP de frames (Aba 2)", file_types=[".zip"], type="filepath")
374
+ batch = gr.Slider(1, 16, value=4, step=1, label="📊 Batch size (DEMO)")
375
+ btn3 = gr.Button("🚀 Processar Segmentação (DEMO)", variant="primary")
376
+ with gr.Column():
377
+ log3 = gr.Textbox(label="📋 Log", lines=16, interactive=False)
378
+ zip_out_3 = gr.File(label="📥 ZIP (segmentação mock)")
379
+ csv_out_3 = gr.File(label="📊 CSV (mock)")
380
+
381
+ frames_zip.change(fn=lambda x: x, inputs=[frames_zip], outputs=[zip_in_3])
382
+
383
+ btn3.click(
384
+ fn=aba3_demo_segmentacao,
385
+ inputs=[zip_in_3, batch],
386
+ outputs=[zip_out_3, csv_out_3, log3],
387
+ )
388
+
389
+ # -------- Aba 4
390
+ with gr.Tab("4️⃣ Redimensionar 224×224 (DEMO)"):
391
+ gr.Markdown("## 🧰 Redimensionar para 224×224 (DEMO)")
392
+ with gr.Row():
393
+ with gr.Column():
394
+ zip_in_4 = gr.File(label="📦 ZIP da Aba 3", file_types=[".zip"], type="filepath")
395
+ btn4 = gr.Button("🚀 Redimensionar (DEMO)", variant="primary")
396
+ with gr.Column():
397
+ log4 = gr.Textbox(label="📋 Log", lines=16, interactive=False)
398
+ zip_out_4 = gr.File(label="📥 ZIP 224×224 (mock)")
399
+ csv_out_4 = gr.File(label="📊 Manifest CSV (mock)")
400
+
401
+ zip_out_3.change(fn=lambda x: x, inputs=[zip_out_3], outputs=[zip_in_4])
402
+
403
+ btn4.click(
404
+ fn=aba4_demo_redimensionar,
405
+ inputs=[zip_in_4],
406
+ outputs=[zip_out_4, csv_out_4, log4],
407
+ )
408
+
409
+ # -------- Aba 5
410
+ with gr.Tab("5️⃣ Inferência (ViT) (DEMO)"):
411
+ gr.Markdown(
412
+ """
413
+ ## 🧪 Inferência com ViT (DEMO)
414
+
415
+ **Passo 1:** Preparar ZIPs por classe (mock)
416
+ **Passo 2:** Selecionar classe e gerar CSV/GeoJSON (mock)
417
+ """
418
+ )
419
+
420
+ with gr.Row():
421
+ with gr.Column():
422
+ gr.Markdown("### 📦 Passo 1: Preparar ZIPs por Classe (DEMO)")
423
+ zip_in_5 = gr.File(label="📦 ZIP 224×224 (Aba 4)", file_types=[".zip"], type="filepath")
424
+ btn5_prep = gr.Button("🔧 Preparar ZIPs (DEMO)", variant="secondary")
425
+ with gr.Column():
426
+ log5_prep = gr.Textbox(label="📋 Log Preparação", lines=8, interactive=False)
427
+ road_zip = gr.File(label="🛣️ Road ZIP (mock)", visible=False)
428
+ sidewalk_zip = gr.File(label="🚶 Sidewalk ZIP (mock)", visible=False)
429
+ grass_zip = gr.File(label="🌱 Grass ZIP (mock)", visible=False)
430
+
431
+ zip_out_4.change(fn=lambda x: x, inputs=[zip_out_4], outputs=[zip_in_5])
432
+
433
+ gr.Markdown("---")
434
+ with gr.Row():
435
+ with gr.Column():
436
+ gr.Markdown("### 🧠 Passo 2: Executar Inferência (DEMO)")
437
+ classe_dd = gr.Dropdown(label="🎯 Selecione a Classe", choices=[], value=None, interactive=True)
438
+ model_in = gr.File(label="🧠 Modelo ViT (.pth) (opcional, ignorado no DEMO)", file_types=[".pth"], type="filepath")
439
+ meta_in = gr.File(label="📄 metadata.json (opcional, ignorado no DEMO)", file_types=[".json"], type="filepath")
440
+ btn5_inf = gr.Button("🚀 Executar Inferência (DEMO)", variant="primary")
441
+ with gr.Column():
442
+ log5_inf = gr.Textbox(label="📋 Log Inferência", lines=12, interactive=False)
443
+ csv_out_5 = gr.File(label="📊 CSV Resultados (mock)")
444
+ geo_out_5 = gr.File(label="🗺️ GeoJSON (mock)")
445
+
446
+ btn5_prep.click(
447
+ fn=aba5_demo_preparar_zips,
448
+ inputs=[zip_in_5],
449
+ outputs=[log5_prep, road_zip, sidewalk_zip, grass_zip, classe_dd],
450
+ )
451
+
452
+ btn5_inf.click(
453
+ fn=aba5_demo_inferencia,
454
+ inputs=[classe_dd, model_in, meta_in],
455
+ outputs=[csv_out_5, geo_out_5, log5_inf],
456
+ )
457
+
458
+ gr.Markdown(
459
+ """
460
+ ---
461
+ ### 📖 Observação
462
+ Este Space é um **DEMO de interface**. Se você quiser a versão “real” (processamento + segmentação + inferência),
463
+ aí sim entra torch/transformers/opencv/exiftool e (idealmente) Docker.
464
+ """
465
+ )
466
+
467
+ return app
468
+
469
+
470
+ if __name__ == "__main__":
471
+ app = create_interface()
472
+ app.launch(server_name="0.0.0.0", server_port=7860, share=False, show_error=True)
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ gradio>=4.26.0