aiqtech commited on
Commit
c61c4a7
ยท
verified ยท
1 Parent(s): 37ae5d9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -35
app.py CHANGED
@@ -702,28 +702,16 @@ with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
702
 
703
 
704
 
705
-
706
- def get_text_params():
707
- """ํ…์ŠคํŠธ ํŒŒ๋ผ๋ฏธํ„ฐ ๊ฐ€์ ธ์˜ค๊ธฐ"""
708
- return {
709
- 'text': text_input.value,
710
- 'font_size': font_size.value,
711
- 'thickness': thickness.value,
712
- 'color': color_dropdown.value,
713
- 'opacity': opacity_slider.value,
714
- 'x_position': text_x_position.value,
715
- 'y_position': text_y_position.value
716
- }
717
-
718
-
719
-
720
- # ์œ„์น˜ ๋ฒ„ํŠผ ์ด๋ฒคํŠธ
721
- for btn, pos in [
722
- (btn_top_left, "top-left"), (btn_top_center, "top-center"), (btn_top_right, "top-right"),
723
- (btn_middle_left, "middle-left"), (btn_middle_center, "middle-center"), (btn_middle_right, "middle-right"),
724
- (btn_bottom_left, "bottom-left"), (btn_bottom_center, "bottom-center"), (btn_bottom_right, "bottom-right")
725
- ]:
726
- btn.click(fn=lambda p=pos: p, outputs=position)
727
 
728
  # ์ด๋ฒคํŠธ ๋ฐ”์ธ๋”ฉ
729
  input_image.change(
@@ -747,7 +735,7 @@ def get_text_params():
747
  queue=False
748
  )
749
 
750
- # ์œ„์น˜ ๋ฒ„ํŠผ ์ด๋ฒคํŠธ
751
  for btn, pos in [
752
  (btn_top_left, "top-left"), (btn_top_center, "top-center"), (btn_top_right, "top-right"),
753
  (btn_middle_left, "middle-left"), (btn_middle_center, "middle-center"), (btn_middle_right, "middle-right"),
@@ -765,29 +753,20 @@ def get_text_params():
765
  aspect_ratio,
766
  position,
767
  scale_slider,
768
- # ํ…์ŠคํŠธ ํŒŒ๋ผ๋ฏธํ„ฐ๋ฅผ ์ง์ ‘ ์ „๋‹ฌ
769
- {
770
- 'text': text_input,
771
- 'font_size': font_size,
772
- 'thickness': thickness,
773
- 'color': color_dropdown,
774
- 'opacity': opacity_slider,
775
- 'x_position': text_x_position,
776
- 'y_position': text_y_position
777
- }
778
  ],
779
  outputs=[combined_image, extracted_image],
780
  queue=True
781
  )
782
 
 
783
  if HF_TOKEN:
784
  login(token=HF_TOKEN, add_to_git_credential=False)
785
 
786
- # FLUX ํŒŒ์ดํ”„๋ผ์ธ ์ดˆ๊ธฐํ™” ์ˆ˜์ •
787
  pipe = FluxPipeline.from_pretrained(
788
  "black-forest-labs/FLUX.1-dev",
789
  torch_dtype=torch.float16,
790
- token=HF_TOKEN # use_auth_token ๋Œ€์‹  token ์‚ฌ์šฉ
791
  )
792
 
793
  demo.queue(max_size=5)
 
702
 
703
 
704
 
705
+ def get_text_params():
706
+ return {
707
+ 'text': text_input.value,
708
+ 'font_size': font_size.value,
709
+ 'thickness': thickness.value,
710
+ 'color': color_dropdown.value,
711
+ 'opacity': opacity_slider.value,
712
+ 'x_position': text_x_position.value,
713
+ 'y_position': text_y_position.value
714
+ }
 
 
 
 
 
 
 
 
 
 
 
 
715
 
716
  # ์ด๋ฒคํŠธ ๋ฐ”์ธ๋”ฉ
717
  input_image.change(
 
735
  queue=False
736
  )
737
 
738
+ # ์œ„์น˜ ๋ฒ„ํŠผ ์ด๋ฒคํŠธ (ํ•œ ๋ฒˆ๋งŒ ์ •์˜)
739
  for btn, pos in [
740
  (btn_top_left, "top-left"), (btn_top_center, "top-center"), (btn_top_right, "top-right"),
741
  (btn_middle_left, "middle-left"), (btn_middle_center, "middle-center"), (btn_middle_right, "middle-right"),
 
753
  aspect_ratio,
754
  position,
755
  scale_slider,
756
+ gr.State(get_text_params) # State ๊ฐ์ฒด๋กœ ๊ฐ์‹ธ์„œ ์ „๋‹ฌ
 
 
 
 
 
 
 
 
 
757
  ],
758
  outputs=[combined_image, extracted_image],
759
  queue=True
760
  )
761
 
762
+ # HF ํ† ํฐ ๋ฐ ํŒŒ์ดํ”„๋ผ์ธ ์ดˆ๊ธฐํ™”
763
  if HF_TOKEN:
764
  login(token=HF_TOKEN, add_to_git_credential=False)
765
 
 
766
  pipe = FluxPipeline.from_pretrained(
767
  "black-forest-labs/FLUX.1-dev",
768
  torch_dtype=torch.float16,
769
+ token=HF_TOKEN
770
  )
771
 
772
  demo.queue(max_size=5)