Surn commited on
Commit
cbd2c0d
·
1 Parent(s): 047a94c

Sketch height

Browse files
Files changed (2) hide show
  1. app.py +25 -8
  2. modules/misc.py +8 -1
app.py CHANGED
@@ -78,7 +78,8 @@ from modules.constants import (
78
  from modules.misc import (
79
  get_filename,
80
  convert_ratio_to_dimensions,
81
- update_dimensions_on_ratio
 
82
  )
83
  from modules.lora_details import (
84
  approximate_token_count,
@@ -100,9 +101,19 @@ user_info = {
100
  "path_params": None,
101
  "level" : 0
102
  }
 
 
 
 
 
 
 
103
  # Define a function to handle the login button click and retrieve user information.
104
- def handle_login(request: gr.Request):
105
- # Extract user information from the request
 
 
 
106
  user_info = {
107
  "username": request.username,
108
  "session_hash": request.session_hash,
@@ -112,7 +123,7 @@ def handle_login(request: gr.Request):
112
  "path_params": dict(request.path_params),
113
  "level" : (0 if request.username == "guest" else 2)
114
  }
115
- return user_info, gr.update(logout_value=f"Logout {user_info['username']} ({user_info['level']})", value=f"Login {user_info['username']} ({user_info['level']})")
116
  #---if workspace = local or colab---
117
 
118
  # Authenticate with Hugging Face
@@ -712,7 +723,7 @@ def getVersions():
712
  run_lora.zerogpu = True
713
  gr.set_static_paths(paths=["images/","images/images","images/prerendered","LUT/","fonts/", "assets/"])
714
  title = "MapLore Magic (Development Features for HexaGrid)"
715
- with gr.Blocks(css_paths="style_20250314.css", title=title, theme='Surn/beeuty', delete_cache=(43200, 43200), head_paths="head.htm") as app:
716
  with gr.Row():
717
  gr.Markdown("""
718
  # MapLore Magic (Development Features for HexaGrid)
@@ -834,7 +845,8 @@ with gr.Blocks(css_paths="style_20250314.css", title=title, theme='Surn/beeuty',
834
  key="imgSketch",
835
  image_mode="RGBA",
836
  format="PNG",
837
- brush=gr.Brush()
 
838
  )
839
  with gr.Row():
840
  with gr.Column(scale=1):
@@ -970,13 +982,18 @@ with gr.Blocks(css_paths="style_20250314.css", title=title, theme='Surn/beeuty',
970
  randomize_seed = gr.Checkbox(False, label="Randomize seed",elem_id="rnd_seed_chk")
971
  seed = gr.Slider(label="Seed", minimum=0, maximum=MAX_SEED, step=1, value=0, randomize=True, elem_id="rnd_seed")
972
  lora_scale = gr.Slider(label="LoRA Scale", minimum=0, maximum=3, step=0.01, value=1.01)
973
- with gr.Row():
974
  login_button = gr.LoginButton(logout_value=f"Logout({user_info['username']} ({user_info['level']}))", size="md", elem_classes="solid centered", elem_id="hf_login_btn", icon="./assets/favicon.ico")
975
  # Create a JSON component to display the user information
976
  user_info_output = gr.JSON(label="User Information:")
977
 
978
  # Set up the event listener for the login button click
979
- login_button.click(fn=handle_login, inputs=[], outputs=[user_info_output, login_button])
 
 
 
 
 
980
  with gr.Row():
981
  gr.HTML(value=getVersions(), visible=True, elem_id="versions")
982
 
 
78
  from modules.misc import (
79
  get_filename,
80
  convert_ratio_to_dimensions,
81
+ update_dimensions_on_ratio,
82
+ wait5
83
  )
84
  from modules.lora_details import (
85
  approximate_token_count,
 
101
  "path_params": None,
102
  "level" : 0
103
  }
104
+
105
+ user_profile = gr.State(None)
106
+
107
+ def get_profile() -> gr.OAuthProfile | None:
108
+ global user_profile
109
+ return user_profile
110
+
111
  # Define a function to handle the login button click and retrieve user information.
112
+ def handle_login(profile: gr.OAuthProfile | None, request: gr.Request):
113
+ # Extract user information from the request
114
+ if profile is None:
115
+ profile = gr.State(None)
116
+ profile = get_profile()
117
  user_info = {
118
  "username": request.username,
119
  "session_hash": request.session_hash,
 
123
  "path_params": dict(request.path_params),
124
  "level" : (0 if request.username == "guest" else 2)
125
  }
126
+ return user_info, gr.update(logout_value=f"Logout {user_info['username']} ({user_info['level']})", value=f"Login {user_info['username']} ({user_info['level']})"), profile
127
  #---if workspace = local or colab---
128
 
129
  # Authenticate with Hugging Face
 
723
  run_lora.zerogpu = True
724
  gr.set_static_paths(paths=["images/","images/images","images/prerendered","LUT/","fonts/", "assets/"])
725
  title = "MapLore Magic (Development Features for HexaGrid)"
726
+ with gr.Blocks(css_paths="style_20250314.css", title=title, theme='Surn/beeuty@==0.5.12', delete_cache=(43200, 43200), head_paths="head.htm") as app:
727
  with gr.Row():
728
  gr.Markdown("""
729
  # MapLore Magic (Development Features for HexaGrid)
 
845
  key="imgSketch",
846
  image_mode="RGBA",
847
  format="PNG",
848
+ brush=gr.Brush(),
849
+ height=300
850
  )
851
  with gr.Row():
852
  with gr.Column(scale=1):
 
982
  randomize_seed = gr.Checkbox(False, label="Randomize seed",elem_id="rnd_seed_chk")
983
  seed = gr.Slider(label="Seed", minimum=0, maximum=MAX_SEED, step=1, value=0, randomize=True, elem_id="rnd_seed")
984
  lora_scale = gr.Slider(label="LoRA Scale", minimum=0, maximum=3, step=0.01, value=1.01)
985
+ with gr.Row():
986
  login_button = gr.LoginButton(logout_value=f"Logout({user_info['username']} ({user_info['level']}))", size="md", elem_classes="solid centered", elem_id="hf_login_btn", icon="./assets/favicon.ico")
987
  # Create a JSON component to display the user information
988
  user_info_output = gr.JSON(label="User Information:")
989
 
990
  # Set up the event listener for the login button click
991
+ login_button.click(fn=wait5, inputs=[gr.State("Login/logout"), gr.State(10)], outputs=[]
992
+ ).then(
993
+ fn=handle_login,
994
+ inputs=[],
995
+ outputs=[user_info_output, login_button, user_profile]
996
+ )
997
  with gr.Row():
998
  gr.HTML(value=getVersions(), visible=True, elem_id="versions")
999
 
modules/misc.py CHANGED
@@ -1,6 +1,7 @@
1
  # misc.py file contains miscellaneous utility functions
2
  import math
3
  import sys
 
4
  #import logging
5
  #import os
6
  #import subprocess
@@ -41,7 +42,13 @@ def get_extension(file):
41
  if file is not None:
42
  extension = file.name.split(".")[-1]
43
  return extension
44
-
 
 
 
 
 
 
45
 
46
  def convert_ratio_to_dimensions(ratio, height=512, rotate90=False):
47
  """
 
1
  # misc.py file contains miscellaneous utility functions
2
  import math
3
  import sys
4
+ import time
5
  #import logging
6
  #import os
7
  #import subprocess
 
42
  if file is not None:
43
  extension = file.name.split(".")[-1]
44
  return extension
45
+ def wait5(message: str = "", sleepytime: int = 5) -> str:
46
+ """
47
+ Waits for 5 seconds.
48
+ """
49
+ print(f"Waiting for 5 seconds...{message}")
50
+ time.sleep(sleepytime)
51
+ return message
52
 
53
  def convert_ratio_to_dimensions(ratio, height=512, rotate90=False):
54
  """