Commit
·
bc9a8f6
1
Parent(s):
989842c
test space without diffusers
Browse files- Dockerfile +1 -9
- README.md +1 -0
- app.py +10 -30
- requirements.txt +1 -5
Dockerfile
CHANGED
@@ -4,16 +4,8 @@ WORKDIR /app
|
|
4 |
|
5 |
COPY ./requirements.txt /app/requirements.txt
|
6 |
|
7 |
-
RUN pip install --upgrade pip
|
8 |
RUN pip install --no-cache-dir --upgrade -r /app/requirements.txt
|
9 |
|
10 |
-
|
11 |
-
USER user
|
12 |
-
ENV HOME=/home/user \
|
13 |
-
PATH=/home/user/.local/bin:$PATH
|
14 |
-
|
15 |
-
WORKDIR $HOME/app
|
16 |
-
|
17 |
-
COPY --chown=user . $HOME/app
|
18 |
|
19 |
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
4 |
|
5 |
COPY ./requirements.txt /app/requirements.txt
|
6 |
|
|
|
7 |
RUN pip install --no-cache-dir --upgrade -r /app/requirements.txt
|
8 |
|
9 |
+
COPY . .
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
|
README.md
CHANGED
@@ -4,6 +4,7 @@ emoji: 🖼️
|
|
4 |
colorFrom: gray
|
5 |
colorTo: purple
|
6 |
sdk: docker
|
|
|
7 |
pinned: false
|
8 |
license: mit
|
9 |
---
|
|
|
4 |
colorFrom: gray
|
5 |
colorTo: purple
|
6 |
sdk: docker
|
7 |
+
app_file: app.py
|
8 |
pinned: false
|
9 |
license: mit
|
10 |
---
|
app.py
CHANGED
@@ -1,29 +1,7 @@
|
|
1 |
import gradio as gr
|
2 |
-
# from diffusers import StableDiffusionPipeline
|
3 |
import torch
|
4 |
|
5 |
-
# device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
6 |
-
|
7 |
-
# pipe = StableDiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5-pruned-emaonly")
|
8 |
-
# pipe = pipe.to(device)
|
9 |
-
|
10 |
def generate_image(prompt, negative_prompt, seed, guidance_scale, num_inference_steps):
|
11 |
-
|
12 |
-
"""
|
13 |
-
generator = torch.Generator().manual_seed(seed)
|
14 |
-
|
15 |
-
image = pipe(
|
16 |
-
prompt=prompt,
|
17 |
-
negative_prompt=negative_prompt,
|
18 |
-
guidance_scale=guidance_scale,
|
19 |
-
num_inference_steps=num_inference_steps,
|
20 |
-
width=512,
|
21 |
-
height=512,
|
22 |
-
generator=generator,
|
23 |
-
).images[0]
|
24 |
-
|
25 |
-
return image
|
26 |
-
"""
|
27 |
return torch.rand(512, 512, 3)
|
28 |
|
29 |
css="""
|
@@ -33,17 +11,19 @@ css="""
|
|
33 |
}
|
34 |
"""
|
35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
with gr.Blocks(css=css) as demo:
|
37 |
|
38 |
with gr.Column(elem_id="col-container"):
|
39 |
-
gr.Markdown(
|
40 |
-
# Text-to-Image: Stable Diffusion from Scratch
|
41 |
-
### By [Nazareno Amidolare](https://kepler296e.github.io/)
|
42 |
-
Using [Docker](https://www.docker.com/), [FastAPI](https://fastapi.tiangolo.com/), [PyTorch](https://pytorch.org/) and [Gradio](https://www.gradio.app/).
|
43 |
-
### References
|
44 |
-
- [Coding Stable Diffusion from scratch in PyTorch](https://www.youtube.com/watch?v=ZBKpAp_6TGI&ab_channel=UmarJamil)
|
45 |
-
- [Hugging Space Diffusers](https://github.com/huggingface/diffusers/)
|
46 |
-
""")
|
47 |
|
48 |
with gr.Row():
|
49 |
|
|
|
1 |
import gradio as gr
|
|
|
2 |
import torch
|
3 |
|
|
|
|
|
|
|
|
|
|
|
4 |
def generate_image(prompt, negative_prompt, seed, guidance_scale, num_inference_steps):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
return torch.rand(512, 512, 3)
|
6 |
|
7 |
css="""
|
|
|
11 |
}
|
12 |
"""
|
13 |
|
14 |
+
md = """
|
15 |
+
# Text-to-Image: Stable Diffusion from Scratch
|
16 |
+
### By [Nazareno Amidolare](https://kepler296e.github.io/)
|
17 |
+
Using [Docker](https://www.docker.com/), [FastAPI](https://fastapi.tiangolo.com/), [PyTorch](https://pytorch.org/) and [Gradio](https://www.gradio.app/).
|
18 |
+
### References
|
19 |
+
- [Coding Stable Diffusion from scratch in PyTorch](https://www.youtube.com/watch?v=ZBKpAp_6TGI&ab_channel=UmarJamil)
|
20 |
+
- [Hugging Space Diffusers](https://github.com/huggingface/diffusers/)
|
21 |
+
"""
|
22 |
+
|
23 |
with gr.Blocks(css=css) as demo:
|
24 |
|
25 |
with gr.Column(elem_id="col-container"):
|
26 |
+
gr.Markdown(md)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
|
28 |
with gr.Row():
|
29 |
|
requirements.txt
CHANGED
@@ -1,6 +1,2 @@
|
|
1 |
gradio
|
2 |
-
torch
|
3 |
-
diffusers
|
4 |
-
pillow
|
5 |
-
transformers
|
6 |
-
accelerate
|
|
|
1 |
gradio
|
2 |
+
torch
|
|
|
|
|
|
|
|