Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import gradio as gr
|
| 3 |
+
|
| 4 |
+
IMG_EXTS = {".jpg", ".jpeg", ".png", ".webp", ".bmp", ".gif"}
|
| 5 |
+
|
| 6 |
+
def load_images():
|
| 7 |
+
files = [f for f in os.listdir(".") if os.path.splitext(f)[1].lower() in IMG_EXTS]
|
| 8 |
+
files.sort() # เรียงเลขไฟล์ 0001, 0002, ...
|
| 9 |
+
return [os.path.join(".", f) for f in files]
|
| 10 |
+
|
| 11 |
+
with gr.Blocks(title="Forensic Image Gallery — Phase 1") as demo:
|
| 12 |
+
gr.Markdown("# 🖼️ Forensic Image Gallery — Phase 1\nแสดงภาพทั้งหมดที่อัปโหลดไว้ใน Space นี้")
|
| 13 |
+
gallery = gr.Gallery(
|
| 14 |
+
value=load_images(),
|
| 15 |
+
columns=4,
|
| 16 |
+
height=800,
|
| 17 |
+
show_label=False,
|
| 18 |
+
object_fit="contain",
|
| 19 |
+
preview=True,
|
| 20 |
+
)
|
| 21 |
+
refresh = gr.Button("🔄 Refresh")
|
| 22 |
+
refresh.click(lambda: load_images(), outputs=gallery)
|
| 23 |
+
|
| 24 |
+
demo.launch()
|