adamelliotfields commited on
Commit
de87bdc
1 Parent(s): c16d580

Rename BFL to Black Forest Labs

Browse files
Files changed (3) hide show
  1. lib/api.py +3 -3
  2. lib/config.py +3 -3
  3. pages/2_🎨_Text_to_Image.py +7 -6
lib/api.py CHANGED
@@ -37,7 +37,7 @@ def txt2img_generate(api_key, service, model, inputs, parameters, **kwargs):
37
  if service == "Fal":
38
  headers["Authorization"] = f"Key {api_key}"
39
 
40
- if service == "BFL":
41
  headers["x-key"] = api_key
42
 
43
  json = {}
@@ -51,7 +51,7 @@ def txt2img_generate(api_key, service, model, inputs, parameters, **kwargs):
51
  json = {**parameters, **kwargs}
52
  json["prompt"] = inputs
53
 
54
- if service == "BFL":
55
  json = {**parameters, **kwargs}
56
  json["prompt"] = inputs
57
 
@@ -75,7 +75,7 @@ def txt2img_generate(api_key, service, model, inputs, parameters, **kwargs):
75
 
76
  # BFL is async so we need to poll for result
77
  # https://api.bfl.ml/docs
78
- if service == "BFL":
79
  id = response.json()["id"]
80
  url = f"{Config.SERVICES[service]}/get_result?id={id}"
81
 
 
37
  if service == "Fal":
38
  headers["Authorization"] = f"Key {api_key}"
39
 
40
+ if service == "Black Forest Labs":
41
  headers["x-key"] = api_key
42
 
43
  json = {}
 
51
  json = {**parameters, **kwargs}
52
  json["prompt"] = inputs
53
 
54
+ if service == "Black Forest Labs":
55
  json = {**parameters, **kwargs}
56
  json["prompt"] = inputs
57
 
 
75
 
76
  # BFL is async so we need to poll for result
77
  # https://api.bfl.ml/docs
78
+ if service == "Black Forest Labs":
79
  id = response.json()["id"]
80
  url = f"{Config.SERVICES[service]}/get_result?id={id}"
81
 
lib/config.py CHANGED
@@ -5,7 +5,7 @@ Config = SimpleNamespace(
5
  ICON="⚡",
6
  LAYOUT="wide",
7
  SERVICES={
8
- "BFL": "https://api.bfl.ml/v1",
9
  "Fal": "https://fal.run",
10
  "Hugging Face": "https://api-inference.huggingface.co/models",
11
  "Perplexity": "https://api.perplexity.ai",
@@ -28,13 +28,13 @@ Config = SimpleNamespace(
28
  TXT2IMG_NEGATIVE_PROMPT="ugly, unattractive, disfigured, deformed, mutated, malformed, blurry, grainy, noisy, oversaturated, undersaturated, overexposed, underexposed, worst quality, low details, lowres, watermark, signature, autograph, trademark, sloppy, cluttered",
29
  TXT2IMG_DEFAULT_MODEL={
30
  # The index of model in below lists
31
- "BFL": 2,
32
  "Fal": 0,
33
  "Hugging Face": 2,
34
  },
35
  TXT2IMG_MODELS={
36
  # Model IDs referenced in Text_to_Image.py
37
- "BFL": [
38
  "flux-dev",
39
  "flux-pro",
40
  "flux-pro-1.1",
 
5
  ICON="⚡",
6
  LAYOUT="wide",
7
  SERVICES={
8
+ "Black Forest Labs": "https://api.bfl.ml/v1",
9
  "Fal": "https://fal.run",
10
  "Hugging Face": "https://api-inference.huggingface.co/models",
11
  "Perplexity": "https://api.perplexity.ai",
 
28
  TXT2IMG_NEGATIVE_PROMPT="ugly, unattractive, disfigured, deformed, mutated, malformed, blurry, grainy, noisy, oversaturated, undersaturated, overexposed, underexposed, worst quality, low details, lowres, watermark, signature, autograph, trademark, sloppy, cluttered",
29
  TXT2IMG_DEFAULT_MODEL={
30
  # The index of model in below lists
31
+ "Black Forest Labs": 2,
32
  "Fal": 0,
33
  "Hugging Face": 2,
34
  },
35
  TXT2IMG_MODELS={
36
  # Model IDs referenced in Text_to_Image.py
37
+ "Black Forest Labs": [
38
  "flux-dev",
39
  "flux-pro",
40
  "flux-pro-1.1",
pages/2_🎨_Text_to_Image.py CHANGED
@@ -5,14 +5,15 @@ import streamlit as st
5
 
6
  from lib import Config, ModelPresets, txt2img_generate
7
 
 
8
  SERVICE_SESSION = {
9
- "BFL": "api_key_bfl",
10
  "Fal": "api_key_fal",
11
  "Hugging Face": "api_key_hugging_face",
12
  }
13
 
14
  SESSION_TOKEN = {
15
- "api_key_bfl": os.environ.get("BFL_API_KEY") or None,
16
  "api_key_fal": os.environ.get("FAL_KEY") or None,
17
  "api_key_hugging_face": os.environ.get("HF_TOKEN") or None,
18
  }
@@ -42,8 +43,8 @@ st.set_page_config(
42
  )
43
 
44
  # Initialize Streamlit session state
45
- if "api_key_bfl" not in st.session_state:
46
- st.session_state.api_key_bfl = ""
47
 
48
  if "api_key_fal" not in st.session_state:
49
  st.session_state.api_key_fal = ""
@@ -60,13 +61,13 @@ if "txt2img_messages" not in st.session_state:
60
  if "txt2img_seed" not in st.session_state:
61
  st.session_state.txt2img_seed = 0
62
 
63
- st.logo("logo.svg")
64
  st.sidebar.header("Settings")
65
  service = st.sidebar.selectbox(
66
  "Service",
67
  options=list(SERVICE_SESSION.keys()),
68
- index=1,
69
  disabled=st.session_state.running,
 
70
  )
71
 
72
  # Disable API key input and hide value if set by environment variable; handle empty string value later.
 
5
 
6
  from lib import Config, ModelPresets, txt2img_generate
7
 
8
+ # The token name is the service in lower_snake_case
9
  SERVICE_SESSION = {
10
+ "Black Forest Labs": "api_key_black_forest_labs",
11
  "Fal": "api_key_fal",
12
  "Hugging Face": "api_key_hugging_face",
13
  }
14
 
15
  SESSION_TOKEN = {
16
+ "api_key_black_forest_labs": os.environ.get("BFL_API_KEY") or None,
17
  "api_key_fal": os.environ.get("FAL_KEY") or None,
18
  "api_key_hugging_face": os.environ.get("HF_TOKEN") or None,
19
  }
 
43
  )
44
 
45
  # Initialize Streamlit session state
46
+ if "api_key_black_forest_labs" not in st.session_state:
47
+ st.session_state.api_key_black_forest_labs = ""
48
 
49
  if "api_key_fal" not in st.session_state:
50
  st.session_state.api_key_fal = ""
 
61
  if "txt2img_seed" not in st.session_state:
62
  st.session_state.txt2img_seed = 0
63
 
64
+ st.logo("logo.png")
65
  st.sidebar.header("Settings")
66
  service = st.sidebar.selectbox(
67
  "Service",
68
  options=list(SERVICE_SESSION.keys()),
 
69
  disabled=st.session_state.running,
70
+ index=2, # Hugging Face
71
  )
72
 
73
  # Disable API key input and hide value if set by environment variable; handle empty string value later.