farukbera commited on
Commit
f2ad27e
·
1 Parent(s): 397161c

added hugging face key

Browse files
Files changed (1) hide show
  1. app.py +10 -5
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
- device = "cuda"
21
- # , torch_dtype=torch.float16
22
- device1 = "cpu"
23
- pipe = StableDiffusionImg2ImgPipeline.from_pretrained("runwayml/stable-diffusion-v1-5").to(device1)
24
- pipe1 = DiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5").to(device1)
 
 
 
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():