Testing / app.py
DonImages's picture
Create app.py
cb92b08 verified
raw
history blame
1.28 kB
import gradio as gr
import json
import os
import time
# Paths
image_folder = "Images/" # Folder containing the images
metadata_file = "descriptions.json" # JSON file with image descriptions
# Load metadata
with open(metadata_file, "r") as f:
metadata = json.load(f)
# Function for training with simple console logging
def train_lora_with_progress():
dataset = []
num_images = len(metadata)
progress_log = ""
# Process images and descriptions
for i, (image_name, description) in enumerate(metadata.items()):
image_path = os.path.join(image_folder, image_name)
if os.path.exists(image_path):
dataset.append({"image": image_path, "description": description})
progress_log += f"Processed {i+1}/{num_images}: {image_name}\n"
else:
progress_log += f"Warning: {image_name} not found.\n"
time.sleep(0.5) # Simulate time for each step
return progress_log + f"\nTraining completed with {len(dataset)} valid images."
# Gradio app
demo = gr.Interface(
fn=train_lora_with_progress,
inputs=None,
outputs="text",
title="Train LoRA with Progress Log",
description="Click below to start training and view live progress logs."
)
demo.launch(enable_queue=True)