shin0624 commited on
Commit
68a815b
ยท
verified ยท
1 Parent(s): a0ecea6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -23
app.py CHANGED
@@ -1,30 +1,26 @@
1
  import gradio as gr
2
- from detect import run_detection
3
- from utils import extract_frames
4
- from plot_map import generate_layout
5
- from ultralytics import YOLO
6
 
7
- # GPU์—์„œ ์ž‘๋™ ๊ฐ€๋Šฅํ•œ ์ค‘๊ฐ„ ์‚ฌ์ด์ฆˆ ๋ชจ๋ธ
8
- model = YOLO('yolov8m.pt')
9
 
10
- def process_video(video):
11
- frames = extract_frames(video.name)
12
- detections_per_frame = []
 
 
13
 
14
- for frame in frames:
15
- detections = run_detection(frame, model)
16
- detections_per_frame.append(detections)
17
 
18
- layout_img = generate_layout(detections_per_frame)
19
- return layout_img
20
-
21
- iface = gr.Interface(
22
- fn=process_video,
23
- inputs=gr.Video(label="๊ณต์žฅ ์ž‘์—… ์˜์ƒ ์—…๋กœ๋“œ"),
24
- outputs=gr.Image(label="2D ๊ณต์žฅ ๋ฏธ๋‹ˆ๋งต"),
25
- title="๊ณต์žฅ ๊ตฌ์กฐ ์ธ์‹ ์‹œ๋ฎฌ๋ ˆ์ดํ„ฐ",
26
- description="์ž‘์—… ํ˜„์žฅ ์˜์ƒ์„ ๋ถ„์„ํ•˜์—ฌ ๊ตฌ์กฐ๋ฌผ์˜ ์œ„์น˜๋ฅผ ์ถ”๋ก ํ•˜๊ณ  2D ํ‰๋ฉด๋„๋ฅผ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค."
27
  )
28
 
29
- if __name__ == "__main__":
30
- iface.launch()
 
1
  import gradio as gr
2
+ from detect import detect_objects_in_video
3
+ from map_builder import generate_factory_map
 
 
4
 
5
+ def process_videos(video_paths):
6
+ print("[INFO] ์ž…๋ ฅ๋œ ๋น„๋””์˜ค ์ˆ˜:", len(video_paths))
7
 
8
+ all_detections = []
9
+ for path in video_paths:
10
+ print(f"[INFO] ๋น„๋””์˜ค ์ฒ˜๋ฆฌ ์ค‘: {path}")
11
+ detections = detect_objects_in_video(path)
12
+ all_detections.extend(detections) # ๋ชจ๋“  ๋น„๋””์˜ค์˜ ๊ตฌ์กฐ๋ฌผ ๊ฐ์ง€ ๊ฒฐ๊ณผ๋ฅผ ๋ˆ„์ 
13
 
14
+ # ๊ณต์žฅ ๊ตฌ์กฐ ๋ฏธ๋‹ˆ๋งต ์ƒ์„ฑ
15
+ minimap_image = generate_factory_map(all_detections)
16
+ return minimap_image
17
 
18
+ demo = gr.Interface(
19
+ fn=process_videos,
20
+ inputs=gr.File(file_types=["video"], label="์ž‘์—…์žฅ ์˜์ƒ ์—…๋กœ๋“œ", multiple=True),
21
+ outputs=gr.Image(type="pil", label="๊ณต์žฅ ๊ตฌ์กฐ ๋ฏธ๋‹ˆ๋งต ์‹œ๋ฎฌ๋ ˆ์ด์…˜"),
22
+ title="Factory Layout Simulator",
23
+ description="๋ณต์ˆ˜์˜ ๊ณต์žฅ ์ž‘์—… ์˜์ƒ์—์„œ ๊ตฌ์กฐ๋ฌผ์„ ๊ฐ์ง€ํ•˜๊ณ  2D ๋ฏธ๋‹ˆ๋งต ํ˜•ํƒœ๋กœ ์‹œ๊ฐํ™”ํ•ฉ๋‹ˆ๋‹ค."
 
 
 
24
  )
25
 
26
+ demo.launch()