Transcendental-Programmer commited on
Commit
112b759
Β·
1 Parent(s): afb8be0

Add Dockerfile for Hugging Face Spaces and update README with deployment instructions

Browse files
Files changed (2) hide show
  1. Dockerfile +20 -0
  2. README.md +53 -34
Dockerfile ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.10-slim
2
+
3
+ # Install system dependencies
4
+ RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
5
+
6
+ # Set workdir
7
+ WORKDIR /app
8
+
9
+ # Copy requirements and install
10
+ COPY requirements.txt ./
11
+ RUN pip install --no-cache-dir -r requirements.txt
12
+
13
+ # Copy all code
14
+ COPY . .
15
+
16
+ # Expose Gradio port
17
+ EXPOSE 7860
18
+
19
+ # Run Gradio app
20
+ CMD ["python", "faceforge_ui/app.py"]
README.md CHANGED
@@ -1,37 +1,56 @@
1
  # faceforge
2
  Interactive latent space editor for face generation using pretrained GANs and diffusion models.
3
 
4
- # Latent Space Exploration
5
-
6
- You can find cool things moving between encoded prompts in a conditional diffusion models latent space. This repository is for doing that.
7
-
8
- # Usage
9
-
10
- `pip install -r requirements.txt && python -m main`
11
-
12
- Run the above command to explore. Feel free to mess around with the config to change how sampling is done, font sizes, etc.
13
- Controls:
14
- Q/E: zoom out/in
15
- WASD: move up/left/down/right
16
- Click anywhere to generate a new image
17
- Click an existing point/node to select it
18
- T: modify prompt in selected node
19
- O: delete selected node
20
- P: create a new node
21
- Right click an existing point/node to move it around
22
- M: Switch between sampling modes
23
-
24
- # Notes
25
-
26
- The zero vector for the encoding space corresponds to a kind of "garden". This corresponds to the negative prompt used in CFG. You can see this at the center of circle mode or when going very far from some points in distance mode.
27
-
28
- In circle mode, having multiple prompts on the opposite side from your generation results in heavy negative coefficients which often knocks generation into garbage area of latent space.
29
- To stay inside space of plausible generations, try to balance all sides of the circle.
30
-
31
- In distance mode, your generation will go towards the zero vector if it is not close to any points, because it falls of to 0 with inverse of square distance to each point.
32
-
33
- # Sampling Modes
34
-
35
- Distance sampling assigns weights to each encoding based on its square distance from your control point
36
-
37
- Circle sampling assigns weights to each encoding based on cosine similarity with your control point. Norm is factored in so this is basically just a dot product.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  # faceforge
2
  Interactive latent space editor for face generation using pretrained GANs and diffusion models.
3
 
4
+ ## πŸš€ Deploy on Hugging Face Spaces (Recommended)
5
+
6
+ FaceForge is ready to run as a Gradio app on [Hugging Face Spaces](https://huggingface.co/spaces):
7
+
8
+ 1. **Push your code to a public GitHub repository.**
9
+ 2. **Create a new Space** at https://huggingface.co/spaces (choose the Gradio SDK or Docker SDK).
10
+ 3. **Add your `requirements.txt` and the provided `Dockerfile` to your repo.**
11
+ 4. **Set the entrypoint to `faceforge_ui/app.py`** (the Gradio app).
12
+ 5. **Deploy!** Your app will be live at `https://<your-username>.hf.space`.
13
+
14
+ ### Example Dockerfile (already included):
15
+ ```Dockerfile
16
+ FROM python:3.10-slim
17
+ RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
18
+ WORKDIR /app
19
+ COPY requirements.txt ./
20
+ RUN pip install --no-cache-dir -r requirements.txt
21
+ COPY . .
22
+ EXPOSE 7860
23
+ CMD ["python", "faceforge_ui/app.py"]
24
+ ```
25
+
26
+ ## Local Development (Optional)
27
+
28
+ You can still run FaceForge locally:
29
+
30
+ ```bash
31
+ pip install -r requirements.txt
32
+ python faceforge_ui/app.py
33
+ ```
34
+
35
+ ## Features
36
+ - Latent space exploration and manipulation
37
+ - Attribute direction discovery (PCA/classifier)
38
+ - Custom attribute-preserving loss
39
+ - Modular, testable core
40
+ - Gradio UI for interactive exploration
41
+
42
+ ## Controls (Gradio UI)
43
+ - Enter prompts (comma-separated)
44
+ - Choose sampling mode (distance/circle)
45
+ - Adjust player position sliders
46
+ - Click "Generate" to see results
47
+
48
+ ## Testing
49
+ Run all tests with:
50
+ ```bash
51
+ pytest tests/
52
+ ```
53
+
54
+ ## Notes
55
+ - The backend and frontend are fully integrated for Spaces.
56
+ - For custom model integration, edit the core and backend modules as needed.