Spaces:
Runtime error
Runtime error
added hugging face key
Browse files
app.py
CHANGED
|
@@ -6,7 +6,9 @@ from starlette.responses import StreamingResponse
|
|
| 6 |
from fastapi.responses import FileResponse
|
| 7 |
import io
|
| 8 |
from fastapi.middleware.cors import CORSMiddleware
|
|
|
|
| 9 |
|
|
|
|
| 10 |
app = FastAPI()
|
| 11 |
|
| 12 |
app.add_middleware(
|
|
@@ -17,11 +19,14 @@ app.add_middleware(
|
|
| 17 |
allow_credentials=True,
|
| 18 |
)
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
@app.get("/")
|
| 27 |
async def root():
|
|
|
|
| 6 |
from fastapi.responses import FileResponse
|
| 7 |
import io
|
| 8 |
from fastapi.middleware.cors import CORSMiddleware
|
| 9 |
+
from config import settings
|
| 10 |
|
| 11 |
+
login(settings.huggingface_key)
|
| 12 |
app = FastAPI()
|
| 13 |
|
| 14 |
app.add_middleware(
|
|
|
|
| 19 |
allow_credentials=True,
|
| 20 |
)
|
| 21 |
|
| 22 |
+
|
| 23 |
+
if torch.backends.mps.is_available():
|
| 24 |
+
device = "mps"
|
| 25 |
+
else:
|
| 26 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 27 |
+
|
| 28 |
+
pipe = StableDiffusionImg2ImgPipeline.from_pretrained("runwayml/stable-diffusion-v1-5").to(device)
|
| 29 |
+
pipe1 = DiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5").to(device)
|
| 30 |
|
| 31 |
@app.get("/")
|
| 32 |
async def root():
|