Spaces:
Sleeping
Sleeping
File size: 1,328 Bytes
0faef99 139dd3e 0faef99 92ddd3a 139dd3e 0faef99 139dd3e 92ddd3a 6782e95 139dd3e 92ddd3a 139dd3e 92ddd3a 139dd3e 0faef99 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
import gradio as gr
import tensorflow as tf
from moviepy.editor import VideoFileClip
from ultralytics import YOLO
from core.data import ClassMapping
from core.model import load_classifier
from core.inference import FrameProcessor
print("Tensorflow version " + tf.__version__)
print('Load classifier.')
classifier_path = 'weights/classifier-7.keras'
classifier = load_classifier(classifier_path)
print('Load detector.')
detector_path = 'weights/yolov8n.pt'
detector = YOLO(detector_path)
def fn(video: gr.Video):
print('Process video.')
output = f'Marked-{str(video)}'
clip = VideoFileClip(video)
id_to_name = {
0: 'Flying',
1: 'Landing',
2: 'Other',
3: 'Straight Taxiing',
4: 'Takeoff',
5: 'Turning Maneuver',
}
process_frame = FrameProcessor(detector, classifier, id_to_name)
clip = clip.fl_image(process_frame)
clip.write_videofile(output, fps=clip.fps, audio_codec='aac', logger=None)
return output
inputs = gr.Video(sources=['upload'], label='Input Video')
outputs = gr.Video(interactive=False, label='Aeroplane Position and Action Marked')
examples = [
['examples/ZFLFDfovqls_001310_001320.mp4'] # cspell: disable-line
['examples/Zv7GyH-fpEY_2023.0_2033.0.mp4']
]
iface = gr.Interface(
fn=fn,
inputs=inputs,
outputs=outputs,
examples=examples,
)
iface.launch()
|