Upload app.py
Browse files
app.py
CHANGED
|
@@ -22,11 +22,6 @@ import torch
|
|
| 22 |
import json
|
| 23 |
from langdetect import detect
|
| 24 |
|
| 25 |
-
VALID_USERS = {"user1": "pass123", "admin": "supersecure"} # You can add more
|
| 26 |
-
|
| 27 |
-
def authenticate(username, password):
|
| 28 |
-
return VALID_USERS.get(username) == password
|
| 29 |
-
|
| 30 |
# Load model and processor
|
| 31 |
processor = BlipProcessor.from_pretrained("Salesforce/blip-image-captioning-base")
|
| 32 |
model = BlipForConditionalGeneration.from_pretrained("Salesforce/blip-image-captioning-base").to("cpu")
|
|
@@ -321,29 +316,7 @@ def create_chatbot():
|
|
| 321 |
border-radius: 8px;
|
| 322 |
}
|
| 323 |
""") as demo:
|
| 324 |
-
|
| 325 |
-
with gr.Tab("Login"):
|
| 326 |
-
gr.Markdown("## 🔐 Login to PR1ME")
|
| 327 |
-
user = gr.Textbox(label="Username")
|
| 328 |
-
pwd = gr.Textbox(label="Password", type="password")
|
| 329 |
-
login_btn = gr.Button("Login")
|
| 330 |
-
login_output = gr.Textbox(visible=False)
|
| 331 |
-
|
| 332 |
-
login_status = gr.State(False)
|
| 333 |
-
|
| 334 |
-
def check_login(u, p):
|
| 335 |
-
if authenticate(u, p):
|
| 336 |
-
return True, gr.update(visible=True), ""
|
| 337 |
-
return False, gr.update(visible=False), "❌ Invalid credentials."
|
| 338 |
-
|
| 339 |
-
login_btn.click(fn=check_login, inputs=[user, pwd], outputs=[login_status, login_output, login_output])
|
| 340 |
-
|
| 341 |
with gr.Tab("Chatbot"):
|
| 342 |
-
def show_if_logged_in(is_logged_in):
|
| 343 |
-
return gr.update(visible=is_logged_in)
|
| 344 |
-
|
| 345 |
-
chatbot = gr.Chatbot(visible=False)
|
| 346 |
-
login_status.change(fn=show_if_logged_in, inputs=[login_status], outputs=[chatbot])
|
| 347 |
chatbot = gr.Chatbot(type='messages', elem_id="chatbot-box")
|
| 348 |
audio_output = gr.Audio(type="filepath", visible=False, autoplay=True)
|
| 349 |
state = gr.State([])
|
|
|
|
| 22 |
import json
|
| 23 |
from langdetect import detect
|
| 24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
# Load model and processor
|
| 26 |
processor = BlipProcessor.from_pretrained("Salesforce/blip-image-captioning-base")
|
| 27 |
model = BlipForConditionalGeneration.from_pretrained("Salesforce/blip-image-captioning-base").to("cpu")
|
|
|
|
| 316 |
border-radius: 8px;
|
| 317 |
}
|
| 318 |
""") as demo:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 319 |
with gr.Tab("Chatbot"):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 320 |
chatbot = gr.Chatbot(type='messages', elem_id="chatbot-box")
|
| 321 |
audio_output = gr.Audio(type="filepath", visible=False, autoplay=True)
|
| 322 |
state = gr.State([])
|