Uhhy commited on
Commit
8be51a8
verified
1 Parent(s): ea46d30

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -0
app.py CHANGED
@@ -3,6 +3,26 @@ from PIL import Image
3
  import torch
4
  from diffusers import StableDiffusionImg2ImgPipeline, StableDiffusionInpaintPipeline
5
  import spaces
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
 
7
  # Inicializar los pipelines globalmente
8
  device = "cuda" if torch.cuda.is_available() else "cpu"
 
3
  import torch
4
  from diffusers import StableDiffusionImg2ImgPipeline, StableDiffusionInpaintPipeline
5
  import spaces
6
+ from huggingface_hub import login
7
+ from dotenv import load_dotenv
8
+ import os
9
+
10
+ # Cargar las variables de entorno desde el archivo .env
11
+ load_dotenv()
12
+
13
+ # Obtener el token de Hugging Face del archivo .env
14
+ huggingface_token = os.getenv('HUGGINGFACE_TOKEN')
15
+
16
+ # Autenticaci贸n en Hugging Face
17
+ def huggingface_login(token):
18
+ try:
19
+ login(token)
20
+ print("Autenticaci贸n exitosa con Hugging Face.")
21
+ except Exception as e:
22
+ print(f"Error al autenticar con Hugging Face: {e}")
23
+
24
+ # Llamar a la funci贸n de autenticaci贸n
25
+ huggingface_login(huggingface_token)
26
 
27
  # Inicializar los pipelines globalmente
28
  device = "cuda" if torch.cuda.is_available() else "cpu"