adamelliotfields commited on
Commit
8b00174
β€’
1 Parent(s): 1853e11

Move txt2img aspect ratios to config

Browse files
lib/config.py CHANGED
@@ -5,13 +5,21 @@ Config = SimpleNamespace(
5
  ICON="⚑",
6
  LAYOUT="wide",
7
  TXT2IMG_NEGATIVE_PROMPT="ugly, bad, asymmetrical, malformed, mutated, disgusting, blurry, grainy, oversaturated, undersaturated, overexposed, underexposed, worst quality, low details, lowres, watermark, signature, autograph, trademark",
8
- TXT2IMG_DEFAULT_INDEX=2,
9
  TXT2IMG_MODELS=[
10
  "black-forest-labs/flux.1-dev",
11
  "black-forest-labs/flux.1-schnell",
12
  "stabilityai/stable-diffusion-xl-base-1.0",
13
  ],
14
- TXT2TXT_DEFAULT_INDEX=4,
 
 
 
 
 
 
 
 
15
  TXT2TXT_MODELS=[
16
  "codellama/codellama-34b-instruct-hf",
17
  "meta-llama/llama-2-13b-chat-hf",
 
5
  ICON="⚑",
6
  LAYOUT="wide",
7
  TXT2IMG_NEGATIVE_PROMPT="ugly, bad, asymmetrical, malformed, mutated, disgusting, blurry, grainy, oversaturated, undersaturated, overexposed, underexposed, worst quality, low details, lowres, watermark, signature, autograph, trademark",
8
+ TXT2IMG_DEFAULT_MODEL=2,
9
  TXT2IMG_MODELS=[
10
  "black-forest-labs/flux.1-dev",
11
  "black-forest-labs/flux.1-schnell",
12
  "stabilityai/stable-diffusion-xl-base-1.0",
13
  ],
14
+ TXT2IMG_DEFAULT_AR="1:1",
15
+ TXT2IMG_AR={
16
+ "9:7": (1152, 896),
17
+ "7:4": (1344, 768),
18
+ "1:1": (1024, 1024),
19
+ "4:7": (768, 1344),
20
+ "7:9": (896, 1152),
21
+ },
22
+ TXT2TXT_DEFAULT_MODEL=4,
23
  TXT2TXT_MODELS=[
24
  "codellama/codellama-34b-instruct-hf",
25
  "meta-llama/llama-2-13b-chat-hf",
pages/1_πŸ’¬_Text_Generation.py CHANGED
@@ -42,7 +42,7 @@ model = st.sidebar.selectbox(
42
  "Model",
43
  placeholder="Select a model",
44
  format_func=lambda x: x.split("/")[1],
45
- index=Config.TXT2TXT_DEFAULT_INDEX,
46
  options=Config.TXT2TXT_MODELS,
47
  )
48
  max_tokens = st.sidebar.slider(
 
42
  "Model",
43
  placeholder="Select a model",
44
  format_func=lambda x: x.split("/")[1],
45
+ index=Config.TXT2TXT_DEFAULT_MODEL,
46
  options=Config.TXT2TXT_MODELS,
47
  )
48
  max_tokens = st.sidebar.slider(
pages/2_🎨_Text_to_Image.py CHANGED
@@ -13,13 +13,6 @@ from lib import Config, Presets
13
  HF_TOKEN = os.environ.get("HF_TOKEN")
14
  API_URL = "https://api-inference.huggingface.co/models"
15
  HEADERS = {"Authorization": f"Bearer {HF_TOKEN}", "X-Wait-For-Model": "true", "X-Use-Cache": "false"}
16
- SIZE_AR = {
17
- "9:7": (1152, 896),
18
- "7:4": (1344, 768),
19
- "1:1": (1024, 1024),
20
- "4:7": (768, 1344),
21
- "7:9": (896, 1152),
22
- }
23
  PRESET_MODEL = {
24
  "black-forest-labs/flux.1-dev": Presets.FLUX_1_DEV,
25
  "black-forest-labs/flux.1-schnell": Presets.FLUX_1_SCHNELL,
@@ -66,12 +59,12 @@ model = st.sidebar.selectbox(
66
  "Model",
67
  format_func=lambda x: x.split("/")[1],
68
  options=Config.TXT2IMG_MODELS,
69
- index=Config.TXT2IMG_DEFAULT_INDEX,
70
  )
71
  aspect_ratio = st.sidebar.select_slider(
72
  "Aspect Ratio",
73
- options=list(SIZE_AR.keys()),
74
- value=list(SIZE_AR.keys())[1],
75
  )
76
 
77
  # heading
@@ -85,9 +78,9 @@ parameters = {}
85
  preset = PRESET_MODEL[model]
86
  for param in preset["parameters"]:
87
  if param == "width":
88
- parameters[param] = SIZE_AR[aspect_ratio][0]
89
  if param == "height":
90
- parameters[param] = SIZE_AR[aspect_ratio][1]
91
  if param == "guidance_scale":
92
  parameters[param] = st.sidebar.slider(
93
  "Guidance Scale",
 
13
  HF_TOKEN = os.environ.get("HF_TOKEN")
14
  API_URL = "https://api-inference.huggingface.co/models"
15
  HEADERS = {"Authorization": f"Bearer {HF_TOKEN}", "X-Wait-For-Model": "true", "X-Use-Cache": "false"}
 
 
 
 
 
 
 
16
  PRESET_MODEL = {
17
  "black-forest-labs/flux.1-dev": Presets.FLUX_1_DEV,
18
  "black-forest-labs/flux.1-schnell": Presets.FLUX_1_SCHNELL,
 
59
  "Model",
60
  format_func=lambda x: x.split("/")[1],
61
  options=Config.TXT2IMG_MODELS,
62
+ index=Config.TXT2IMG_DEFAULT_MODEL,
63
  )
64
  aspect_ratio = st.sidebar.select_slider(
65
  "Aspect Ratio",
66
+ options=list(Config.TXT2IMG_AR.keys()),
67
+ value=Config.TXT2IMG_DEFAULT_AR,
68
  )
69
 
70
  # heading
 
78
  preset = PRESET_MODEL[model]
79
  for param in preset["parameters"]:
80
  if param == "width":
81
+ parameters[param] = Config.TXT2IMG_AR[aspect_ratio][0]
82
  if param == "height":
83
+ parameters[param] = Config.TXT2IMG_AR[aspect_ratio][1]
84
  if param == "guidance_scale":
85
  parameters[param] = st.sidebar.slider(
86
  "Guidance Scale",