Spaces:
Runtime error
Runtime error
Update app.py
Browse files91 unmodified lines929394959697989910026 unmodified lines12712812913013113234 unmodified lines16716816917017117217337 unmodified lines21121221321421521621721821922022122222322422522622722822923023123223391 unmodified linesplt.figure(figsize=(10, 10))plt.imshow(image)show_mask(mask, plt.gca(), borders=borders) # Draw the mask with bordersif point_coords is not None:assert input_labels is not Noneshow_points(point_coords, input_labels, plt.gca())if box_coords is not None:show_box(box_coords, plt.gca())if len(scores) > 1:26 unmodified linesreturn combined_images, mask_imagesdef sam_process(input_image, checkpoint, tracking_points, trackings_input_label):image = Image.open(input_image)image = np.array(image.convert("RGB"))34 unmodified linesprint(masks.shape)results, mask_results = show_masks(image, masks, scores, point_coords=input_point, input_labels=input_label, borders=False)print(results)return results[0], mask_results[0]37 unmodified lines)points_map.upload(preprocess_image,points_map,[first_frame_path, tracking_points, trackings_input_label, input_image],queue=False)points_map.select(get_point,[point_type, tracking_points, trackings_input_label, first_frame_path],[tracking_points, trackings_input_label, points_map],queue=False)submit_btn.click(fn = sam_process,inputs = [input_image, checkpoint, tracking_points, trackings_input_label],outputs = [output_result, output_result_mask])demo.launch()91 unmodified lines929394959697989910010110226 unmodified lines12913013113213313413534 unmodified lines17017117217317417517637 unmodified lines21421521621721821922022122222322422522622722822923023123223323423523691 unmodified linesplt.figure(figsize=(10, 10))plt.imshow(image)show_mask(mask, plt.gca(), borders=borders) # Draw the mask with borders"""if point_coords is not None:assert input_labels is not Noneshow_points(point_coords, input_labels, plt.gca())"""if box_coords is not None:show_box(box_coords, plt.gca())if len(scores) > 1:26 unmodified linesreturn combined_images, mask_images@spaces.GPU()def sam_process(input_image, checkpoint, tracking_points, trackings_input_label):image = Image.open(input_image)image = np.array(image.convert("RGB"))34 unmodified linesprint(masks.shape)results, mask_results = show_masks(image, masks, scores, point_coords=input_point, input_labels=input_label, borders=True)print(results)return results[0], mask_results[0]37 unmodified lines)points_map.upload(fn = preprocess_image,inputs = [points_map],outputs = [first_frame_path, tracking_points, trackings_input_label, input_image],queue = False)points_map.select(fn = get_point,inputs = [point_type, tracking_points, trackings_input_label, first_frame_path],outputs = [tracking_points, trackings_input_label, points_map],queue = False)submit_btn.click(fn = sam_process,inputs = [input_image, checkpoint, tracking_points, trackings_input_label],outputs = [output_result, output_result_mask])demo.launch(show_api=False, show_error=True)
app.py+14-11