Shabbir-Anjum commited on
Commit
ec3e88c
·
verified ·
1 Parent(s): c33bba6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -1
app.py CHANGED
@@ -1,10 +1,21 @@
1
  import streamlit as st
2
  from diffusers import DiffusionPipeline
3
  import torch
 
 
 
 
 
4
 
5
  @st.cache_resource
6
  def load_pipeline():
7
- pipeline = DiffusionPipeline.from_pretrained("black-forest-labs/FLUX.1-dev")
 
 
 
 
 
 
8
  pipeline.load_lora_weights("gorkemyurt/lora-train")
9
  return pipeline
10
 
 
1
  import streamlit as st
2
  from diffusers import DiffusionPipeline
3
  import torch
4
+ import os
5
+ from dotenv import load_dotenv
6
+
7
+ # Load environment variables from .env file
8
+ load_dotenv()
9
 
10
  @st.cache_resource
11
  def load_pipeline():
12
+ # Get the token from the environment variable
13
+ token = os.getenv("HUGGING_FACE_HUB_TOKEN")
14
+ if not token:
15
+ st.error("Hugging Face token not found. Please check your .env file.")
16
+ st.stop()
17
+
18
+ pipeline = DiffusionPipeline.from_pretrained("black-forest-labs/FLUX.1-dev", use_auth_token=token)
19
  pipeline.load_lora_weights("gorkemyurt/lora-train")
20
  return pipeline
21