p1atdev commited on
Commit
940a541
β€’
1 Parent(s): 6bc2138

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -10
app.py CHANGED
@@ -49,7 +49,7 @@ TEMPLATE = (
49
  #
50
  "<|rating:general|>"
51
  "{aspect_ratio}"
52
- "<|length:long|>"
53
  #
54
  "<copyright></copyright>"
55
  #
@@ -57,8 +57,8 @@ TEMPLATE = (
57
  #
58
  "<general>{subject}"
59
  )
60
- QUALITY_TAGS = "original style"
61
- NEGATIVE_PROMPT = ",(bad quality, worst quality:1.1), lowres, bad anatomy, sketch, jpeg artifacts, ugly, poorly drawn, signature, watermark, bad anatomy, bad hands, bad feet, retro, old, 2000s, 2010s, 2011s, 2012s, 2013s, multiple views, 3d, screencap"
62
  BAN_TAGS = [
63
  "photoshop (medium)",
64
  "clip studio paint (medium)",
@@ -126,18 +126,22 @@ else:
126
 
127
 
128
  def get_aspect_ratio(width: int, height: int) -> str:
129
- ar = width / height
130
 
131
- if ar <= 1 / math.sqrt(3):
132
- return "<|aspect_ratio:ultra_tall|>"
133
- elif ar <= 8 / 9:
 
 
134
  return "<|aspect_ratio:tall|>"
135
- elif ar < 9 / 8:
136
  return "<|aspect_ratio:square|>"
137
- elif ar < math.sqrt(3):
138
  return "<|aspect_ratio:wide|>"
 
 
139
  else:
140
- return "<|aspect_ratio:ultra_wide|>"
141
 
142
 
143
  @torch.inference_mode
 
49
  #
50
  "<|rating:general|>"
51
  "{aspect_ratio}"
52
+ "<|length:medium|>"
53
  #
54
  "<copyright></copyright>"
55
  #
 
57
  #
58
  "<general>{subject}"
59
  )
60
+ QUALITY_TAGS = ""
61
+ NEGATIVE_PROMPT = "bad quality, worst quality, lowres, bad anatomy, sketch, jpeg artifacts, ugly, poorly drawn, signature, watermark, bad anatomy, bad hands, bad feet, retro, old, 2000s, 2010s, 2011s, 2012s, 2013s, multiple views, 3d, screencap"
62
  BAN_TAGS = [
63
  "photoshop (medium)",
64
  "clip studio paint (medium)",
 
126
 
127
 
128
  def get_aspect_ratio(width: int, height: int) -> str:
129
+ ar = math.log2(width / height)
130
 
131
+ if ar <= -1.25:
132
+ return "<|aspect_ratio:too_tall|>"
133
+ elif ar <= -0.75:
134
+ return "<|aspect_ratio:tall_wallpaper|>"
135
+ elif ar <= -0.25:
136
  return "<|aspect_ratio:tall|>"
137
+ elif ar < 0.25:
138
  return "<|aspect_ratio:square|>"
139
+ elif ar < 0.75:
140
  return "<|aspect_ratio:wide|>"
141
+ elif ar < 1.25:
142
+ return "<|aspect_ratio:wide_wallpaper|>"
143
  else:
144
+ return "<|aspect_ratio:too_wide|>"
145
 
146
 
147
  @torch.inference_mode