Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
TakanoTaiga committed Oct 2, 2024
1 parent 5d16aca commit aa0d34d
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions gradio_web_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,22 @@

mode_list = ["Create Fully Annotated Video", "Create Time-Lapse Video", "Do Not Create Video"]


def upload_mlmodel(filepaths):
dest_dir = './ml_model'

if not os.path.exists(dest_dir):
os.makedirs(dest_dir)

for filepath in filepaths:
if os.path.isfile(filepath):
shutil.copy(filepath, dest_dir)
else:
return f'{filepath} is not found'

return "Upload complete. Please restart gradio_web_ui.py"


def inference_image(image, mlmodel_name: str, confidence: float):
model = RTDETR(mlmodel_name)
results = model.predict(
Expand Down Expand Up @@ -62,12 +64,11 @@ def infer_video(videos, mlmodel_name: str, confidence: float, mode: float, progr

if mode_list[0] == mode or mode_list[1] == mode:
height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
output_file = tempfile.NamedTemporaryFile(delete=False, suffix='.mp4').name
out = cv2.VideoWriter(output_file, fourcc, fps, (width, height))


try:
while cap.isOpened():
ret, frame = cap.read()
Expand Down Expand Up @@ -169,8 +170,8 @@ def infer_video(videos, mlmodel_name: str, confidence: float, mode: float, progr
info="Choose between 0% and 100%"
),
gr.Radio(
mode_list,
label="Video Creation Options",
mode_list,
label="Video Creation Options",
info="Choose the type of video to create: fully annotated, time-lapse, or none."
),
],
Expand Down

0 comments on commit aa0d34d

Please sign in to comment.