Spaces:
Running
Running
update-gradio (#3)
Browse files- Update licence (128831be86625cf07c820ec3746883d7ead110b3)
- Update requirements (480bc123d88871d3641d3ca177ff3d66d93a609c)
- Update interaction code (04dd7ac440b8da8386a4d36c08b23e7af4dd296e)
Files changed (4)
- LICENCE+1-1
- README.md+1-1
- app.py+10-14
- requirements.txt+9-8
123456The MIT License (MIT)Copyright (c) 2023 Alessandro ContiPermission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to deal123456The MIT License (MIT)Copyright (c) 2024 Alessandro ContiPermission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to deal
3 unmodified lines456789103 unmodified linescolorFrom: greencolorTo: yellowsdk: gradiosdk_version: '4.36.0'python_version: '3.9'app_file: app.pypinned: false3 unmodified lines456789103 unmodified linescolorFrom: greencolorTo: yellowsdk: gradiosdk_version: '4.44.1'python_version: '3.9'app_file: app.pypinned: false
42 unmodified lines434445464748491 unmodified line5152535455565758596061626323 unmodified lines8788899091929394951 unmodified line9798991001011021031041052 unmodified lines10810911011111211311411511611742 unmodified linesPROCESSOR = CLIPProcessor.from_pretrained("openai/clip-vit-large-patch14")def save_original_image(image: gr.Image):if image is None:return None, None1 unmodified linesize = min(size) if isinstance(size, tuple) else sizeimage = resize(image, size)return image, image.copy()def prepare_image(image: gr.Image):if image is None:return None, NonePROCESSOR.image_processor.do_normalize = Falseimage_tensor = PROCESSOR(images=[image], return_tensors="pt", padding=True)PROCESSOR.image_processor.do_normalize = True23 unmodified linesgr.Markdown(MARKDOWN_DESCRIPTION)with gr.Row():with gr.Column():curr_image = gr.Image(label="input", type="pil")_orig_image = gr.Image(label="orig. image", type="pil", visible=False, interactive=False)alpha_slider = gr.Slider(0.0, 1.0, value=0.7, step=0.1, label="alpha")with gr.Row():1 unmodified linerun_button = gr.Button(value="Submit", variant="primary")with gr.Column():output_label = gr.Label(label="output", num_top_classes=5)examples = gr.Examples(examples=glob(os.path.join(os.path.dirname(__file__), "examples", "*.jpg")),inputs=[_orig_image],outputs=[output_label],fn=image_inference,cache_examples=True,2 unmodified lines# INTERACTIONS# - change_orig_image.change(prepare_image, [_orig_image], [curr_image, _orig_image])# - uploadcurr_image.upload(save_original_image, [curr_image], [curr_image, _orig_image])curr_image.upload(lambda: None, [], [output_label])# - clear42 unmodified lines434445464748491 unmodified line51525354555623 unmodified lines80818283848586871 unmodified line89909192939495969798991001012 unmodified lines10410510610710810911011111211342 unmodified linesPROCESSOR = CLIPProcessor.from_pretrained("openai/clip-vit-large-patch14")def image_preprocess(image: gr.Image):if image is None:return None, None1 unmodified linesize = min(size) if isinstance(size, tuple) else sizeimage = resize(image, size)PROCESSOR.image_processor.do_normalize = Falseimage_tensor = PROCESSOR(images=[image], return_tensors="pt", padding=True)PROCESSOR.image_processor.do_normalize = True23 unmodified linesgr.Markdown(MARKDOWN_DESCRIPTION)with gr.Row():with gr.Column():curr_image = gr.Image(label="input", type="pil", sources=["upload", "webcam", "clipboard"])alpha_slider = gr.Slider(0.0, 1.0, value=0.7, step=0.1, label="alpha")with gr.Row():1 unmodified linerun_button = gr.Button(value="Submit", variant="primary")with gr.Column():output_label = gr.Label(label="output", num_top_classes=5)_orig_image = gr.Image(label="original image", type="pil", visible=False, interactive=False)_example_image = gr.Image(label="example image", type="pil", visible=False, interactive=False)examples = gr.Examples(examples=glob(os.path.join(os.path.dirname(__file__), "examples", "*.jpg")),inputs=[_example_image],outputs=[output_label],fn=image_inference,cache_examples=True,2 unmodified lines# INTERACTIONS# - change_example_image.change(image_preprocess, [_example_image], [curr_image, _orig_image])# - uploadcurr_image.upload(image_preprocess, [curr_image], [curr_image, _orig_image])curr_image.upload(lambda: None, [], [output_label])# - clear
12345678torch==2.0.1torchvision==0.15.2faiss-cpu==1.7.4flair==0.13.0gradio==4.7.1inflect==7.0.0nltk==3.8.1transformers==4.35.1123456789torch>=2,<3torchvision>=0,<1faiss-cpu>=1,<2flair>=0,<1gradio==4.44.1inflect>=7,<8nltk>=3,<4pyarrow>=18,<19transformers>=4,<5
LICENCE+1-1
README.md+1-1
app.py+10-14
requirements.txt+9-8