Spaces:
Runtime error
Runtime error
Axel-Student
commited on
Commit
·
d0ff1b1
1
Parent(s):
84e97df
change dockerfile
Browse files- Dockerfile +6 -0
- app.py +1 -1
Dockerfile
CHANGED
@@ -2,6 +2,12 @@ FROM python:3.10
|
|
2 |
|
3 |
WORKDIR /app
|
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
RUN pip install --no-cache-dir torch torchvision torchaudio diffusers fastapi uvicorn
|
6 |
RUN pip install git+https://github.com/huggingface/diffusers.git
|
7 |
RUN pip install transformers
|
|
|
2 |
|
3 |
WORKDIR /app
|
4 |
|
5 |
+
ENV HF_HOME=/app/hf_cache
|
6 |
+
ENV TRANSFORMERS_CACHE=/app/hf_cache
|
7 |
+
ENV DIFFUSERS_CACHE=/app/hf_cache
|
8 |
+
|
9 |
+
RUN mkdir -p /app/hf_cache
|
10 |
+
|
11 |
RUN pip install --no-cache-dir torch torchvision torchaudio diffusers fastapi uvicorn
|
12 |
RUN pip install git+https://github.com/huggingface/diffusers.git
|
13 |
RUN pip install transformers
|
app.py
CHANGED
@@ -4,12 +4,12 @@ import torch
|
|
4 |
from fastapi import FastAPI, HTTPException
|
5 |
from fastapi.responses import StreamingResponse
|
6 |
from diffusers import FluxPipeline # type: ignore
|
|
|
7 |
|
8 |
app = FastAPI()
|
9 |
|
10 |
# Récupération du token et authentification
|
11 |
token = os.getenv("HF_TOKEN")
|
12 |
-
|
13 |
pipe = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-dev", torch_dtype=torch.bfloat16)
|
14 |
pipe.enable_model_cpu_offload()
|
15 |
|
|
|
4 |
from fastapi import FastAPI, HTTPException
|
5 |
from fastapi.responses import StreamingResponse
|
6 |
from diffusers import FluxPipeline # type: ignore
|
7 |
+
from huggingface_hub import login
|
8 |
|
9 |
app = FastAPI()
|
10 |
|
11 |
# Récupération du token et authentification
|
12 |
token = os.getenv("HF_TOKEN")
|
|
|
13 |
pipe = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-dev", torch_dtype=torch.bfloat16)
|
14 |
pipe.enable_model_cpu_offload()
|
15 |
|