Kims12 commited on
Commit
7b17e69
ยท
verified ยท
1 Parent(s): bdde7fb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -7
app.py CHANGED
@@ -64,13 +64,38 @@ output_file = gr.File(label="Output PNG File")
64
  chameleon = load_img("butterfly.jpg", output_type="pil")
65
  url_example = "https://hips.hearstapps.com/hmg-prod/images/gettyimages-1229892983-square.jpg"
66
 
67
- tab1 = gr.Interface(fn, inputs=image_upload, outputs=slider1, examples=[chameleon], api_name="image")
68
- tab2 = gr.Interface(fn, inputs=url_input, outputs=slider2, examples=[url_example], api_name="text")
69
- tab3 = gr.Interface(process_file, inputs=image_file_upload, outputs=output_file, examples=["butterfly.jpg"], api_name="png")
70
 
71
- demo = gr.TabbedInterface(
72
- [tab1, tab2, tab3], ["Image Upload", "URL Input", "File Output"], title="Background Removal Tool"
73
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
 
75
  if __name__ == "__main__":
76
- demo.launch(show_error=True)
 
64
  chameleon = load_img("butterfly.jpg", output_type="pil")
65
  url_example = "https://hips.hearstapps.com/hmg-prod/images/gettyimages-1229892983-square.jpg"
66
 
67
+ # ๋กœ๊ทธ์ธ ์„น์…˜
 
 
68
 
69
+ def verify_credentials(username, password):
70
+ return username == "abc" and password == "1234"
71
+
72
+ def login(username, password):
73
+ if verify_credentials(username, password):
74
+ return gr.update(visible=False), gr.update(visible=True), "๋กœ๊ทธ์ธ ์„ฑ๊ณต"
75
+ else:
76
+ return gr.update(visible=True), gr.update(visible=False), "์•„์ด๋”” ๋˜๋Š” ๋น„๋ฐ€๋ฒˆํ˜ธ๊ฐ€ ํ‹€๋ ธ์Šต๋‹ˆ๋‹ค."
77
+
78
+ with gr.Blocks() as login_demo:
79
+ with gr.Row() as login_row:
80
+ username = gr.Textbox(label="์•„์ด๋””")
81
+ password = gr.Textbox(label="๋น„๋ฐ€๋ฒˆํ˜ธ", type="password")
82
+ login_button = gr.Button("๋กœ๊ทธ์ธ")
83
+ login_message = gr.Textbox(label="๋ฉ”์‹œ์ง€", interactive=False)
84
+
85
+ with gr.Row(visible=False) as main_app:
86
+ tab1 = gr.Interface(fn, inputs=image_upload, outputs=slider1, examples=[chameleon], api_name="image")
87
+ tab2 = gr.Interface(fn, inputs=url_input, outputs=slider2, examples=[url_example], api_name="text")
88
+ tab3 = gr.Interface(process_file, inputs=image_file_upload, outputs=output_file, examples=["butterfly.jpg"], api_name="png")
89
+
90
+ demo = gr.TabbedInterface(
91
+ [tab1, tab2, tab3], ["Image Upload", "URL Input", "File Output"], title="Background Removal Tool"
92
+ )
93
+
94
+ login_button.click(
95
+ login,
96
+ inputs=[username, password],
97
+ outputs=[login_row, main_app, login_message]
98
+ )
99
 
100
  if __name__ == "__main__":
101
+ login_demo.launch(show_error=True)