Delete app.py
Browse files
app.py
DELETED
|
@@ -1,47 +0,0 @@
|
|
| 1 |
-
import gradio as gr
|
| 2 |
-
import json
|
| 3 |
-
import os
|
| 4 |
-
import time # For simulating progress
|
| 5 |
-
|
| 6 |
-
# Paths
|
| 7 |
-
image_folder = "Images/" # Folder containing the images
|
| 8 |
-
metadata_file = "descriptions.json" # JSON file with image descriptions
|
| 9 |
-
|
| 10 |
-
# Load metadata
|
| 11 |
-
with open(metadata_file, "r") as f:
|
| 12 |
-
metadata = json.load(f)
|
| 13 |
-
|
| 14 |
-
# Placeholder function for training LoRA with progress tracking
|
| 15 |
-
def train_lora_with_progress(image_folder, metadata, progress=gr.Progress()):
|
| 16 |
-
dataset = []
|
| 17 |
-
num_images = len(metadata)
|
| 18 |
-
completed = 0
|
| 19 |
-
|
| 20 |
-
# Start processing images
|
| 21 |
-
for image_name, description in metadata.items():
|
| 22 |
-
image_path = os.path.join(image_folder, image_name)
|
| 23 |
-
if os.path.exists(image_path): # Ensure the image file exists
|
| 24 |
-
dataset.append({"image": image_path, "description": description})
|
| 25 |
-
completed += 1
|
| 26 |
-
progress(completed / num_images, f"Processed {completed}/{num_images} images: {image_name}")
|
| 27 |
-
time.sleep(0.5) # Simulating processing time
|
| 28 |
-
else:
|
| 29 |
-
progress(completed / num_images, f"Warning: {image_name} not found in {image_folder}")
|
| 30 |
-
|
| 31 |
-
# Placeholder for training logic
|
| 32 |
-
return f"Training completed with {len(dataset)} valid images."
|
| 33 |
-
|
| 34 |
-
# Define Gradio app
|
| 35 |
-
def start_training():
|
| 36 |
-
return train_lora_with_progress(image_folder, metadata)
|
| 37 |
-
|
| 38 |
-
# Gradio interface
|
| 39 |
-
demo = gr.Interface(
|
| 40 |
-
fn=start_training,
|
| 41 |
-
inputs=None,
|
| 42 |
-
outputs="text",
|
| 43 |
-
title="Train LoRA with Progress",
|
| 44 |
-
description="Click below to start training with the uploaded images and metadata. Progress will be displayed live."
|
| 45 |
-
)
|
| 46 |
-
|
| 47 |
-
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|