Update app.py
Browse files
app.py
CHANGED
|
@@ -68,9 +68,46 @@ tab1 = gr.Interface(fn, inputs=image_upload, outputs=slider1, examples=[chameleo
|
|
| 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 |
-
|
| 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)
|
|
|
|
| 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_tabs = gr.TabbedInterface(
|
| 72 |
[tab1, tab2, tab3], ["Image Upload", "URL Input", "File Output"], title="Background Removal Tool"
|
| 73 |
)
|
| 74 |
|
| 75 |
+
# 로그인 관련 코드
|
| 76 |
+
def verify_credentials(username, password):
|
| 77 |
+
if username == "abc" and password == "1234":
|
| 78 |
+
return True, "Successfully logged in."
|
| 79 |
+
else:
|
| 80 |
+
return False, "Invalid username or password."
|
| 81 |
+
|
| 82 |
+
def login(username, password):
|
| 83 |
+
success, message = verify_credentials(username, password)
|
| 84 |
+
if success:
|
| 85 |
+
return gr.update(visible=False), gr.update(visible=True), gr.update(value=message)
|
| 86 |
+
else:
|
| 87 |
+
return gr.update(visible=True), gr.update(visible=False), gr.update(value=message)
|
| 88 |
+
|
| 89 |
+
# Gradio 인터페이스 정의
|
| 90 |
+
with gr.Blocks() as demo:
|
| 91 |
+
# 로그인 섹션
|
| 92 |
+
with gr.Row() as login_row:
|
| 93 |
+
with gr.Column():
|
| 94 |
+
gr.Markdown("## Login")
|
| 95 |
+
username = gr.Textbox(label="Username")
|
| 96 |
+
password = gr.Textbox(label="Password", type="password")
|
| 97 |
+
login_button = gr.Button("Login")
|
| 98 |
+
login_message = gr.Textbox(label="Message", interactive=False, visible=False)
|
| 99 |
+
|
| 100 |
+
# 메인 애플리케이션 섹션 (초기에는 숨김)
|
| 101 |
+
with gr.Row(visible=False) as main_app:
|
| 102 |
+
with gr.Column():
|
| 103 |
+
demo_tabs.render()
|
| 104 |
+
|
| 105 |
+
# 로그인 버튼 이벤트 연결
|
| 106 |
+
login_button.click(
|
| 107 |
+
login,
|
| 108 |
+
inputs=[username, password],
|
| 109 |
+
outputs=[login_row, main_app, login_message]
|
| 110 |
+
)
|
| 111 |
+
|
| 112 |
if __name__ == "__main__":
|
| 113 |
demo.launch(show_error=True)
|