|
import zipfile |
|
import gradio as gr |
|
import os |
|
|
|
def unzip_file(file): |
|
extract_path = "extracted_files" |
|
os.makedirs(extract_path, exist_ok=True) |
|
jpg_files = [] |
|
with zipfile.ZipFile(file, "r") as zip_ref: |
|
zip_ref.extractall(extract_path) |
|
|
|
for root, dirs, files in os.walk(extract_path): |
|
for file in files: |
|
if file.lower().endswith('.jpg'): |
|
full_path = os.path.join(root, file) |
|
jpg_files.append(full_path) |
|
|
|
if not jpg_files: |
|
return ["No JPG files found in the zip."] |
|
return jpg_files |
|
|
|
|
|
interface = gr.Interface(fn=unzip_file, inputs="file", outputs=gr.Gallery()) |
|
interface.launch() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|