uhdessai commited on
Commit
5f70fe7
·
1 Parent(s): 718e0cc

initial commit

Browse files
Files changed (3) hide show
  1. .gitignore +34 -0
  2. app.py +44 -0
  3. requirements.txt +7 -0
.gitignore ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ignore outputs (generated images)
2
+ outputs/
3
+ *.png
4
+
5
+ # Ignore model weights (handled separately, e.g. via Git LFS or manual upload)
6
+ model/*.pkl
7
+
8
+ # Python cache
9
+ __pycache__/
10
+ *.py[cod]
11
+ *.so
12
+
13
+ # Jupyter notebooks checkpoint
14
+ .ipynb_checkpoints/
15
+
16
+ # System files
17
+ .DS_Store
18
+ Thumbs.db
19
+
20
+ # Environment or build artifacts
21
+ env/
22
+ venv/
23
+ *.egg-info/
24
+ dist/
25
+ build/
26
+ .cache/
27
+ *.log
28
+
29
+ # VSCode and IDE settings
30
+ .vscode/
31
+ .idea/
32
+
33
+ # Hugging Face specific
34
+ *.sagemaker/
app.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import subprocess
3
+ import os
4
+ import random
5
+ from PIL import Image
6
+
7
+ # Paths
8
+ OUTPUT_DIR = "outputs"
9
+ MODEL_PATH = "model/network-snapshot-000020.pkl" # Adjusted for local Hugging Face repo structure
10
+
11
+ # Ensure the output directory exists
12
+ os.makedirs(OUTPUT_DIR, exist_ok=True)
13
+
14
+ # Function to generate images using StyleGAN3
15
+ def generate_images():
16
+ command = f"python stylegan3/gen_images.py --outdir={OUTPUT_DIR} --trunc=1 --seeds='3-5,7,9,12-14,16-26,29,31,32,34,40,41' --network={MODEL_PATH}"
17
+ try:
18
+ subprocess.run(command, shell=True, check=True)
19
+ except subprocess.CalledProcessError as e:
20
+ return f"Error generating images: {e}"
21
+
22
+ # Function to select 5 random images
23
+ def get_random_images():
24
+ image_files = [f for f in os.listdir(OUTPUT_DIR) if f.endswith(".png")]
25
+ if len(image_files) < 5:
26
+ generate_images()
27
+ image_files = [f for f in os.listdir(OUTPUT_DIR) if f.endswith(".png")]
28
+ random_images = random.sample(image_files, min(5, len(image_files)))
29
+ return [Image.open(os.path.join(OUTPUT_DIR, img)) for img in random_images]
30
+
31
+ # Gradio function
32
+ def generate_and_display():
33
+ generate_images()
34
+ return get_random_images()
35
+
36
+ # UI
37
+ with gr.Blocks() as demo:
38
+ gr.Markdown("# 🎨 AI-Generated Clothing Designs - Dresses")
39
+ generate_button = gr.Button("Generate New Designs")
40
+ output_gallery = gr.Gallery(label="Generated Designs", columns=5, rows=2)
41
+ generate_button.click(fn=generate_and_display, outputs=output_gallery)
42
+
43
+ if __name__ == "__main__":
44
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ gradio==4.26.0
2
+ Pillow==10.2.0
3
+ torch==2.0.1
4
+ torchvision==0.15.2
5
+ torchaudio==2.0.2
6
+ ninja==1.11.1
7
+