Update app.py
Browse files
app.py
CHANGED
@@ -10,6 +10,13 @@ from PIL import Image
|
|
10 |
import os
|
11 |
import torchvision.transforms.functional as TVF
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
CLIP_PATH = "google/siglip-so400m-patch14-384"
|
15 |
MODEL_PATH = "meta-llama/Meta-Llama-3.1-8B"
|
@@ -38,6 +45,11 @@ CAPTION_TYPE_MAP = {
|
|
38 |
|
39 |
HF_TOKEN = os.environ.get("HF_TOKEN", None)
|
40 |
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
class ImageAdapter(nn.Module):
|
43 |
def __init__(self, input_features: int, output_features: int, ln1: bool, pos_emb: bool, num_image_tokens: int, deep_extract: bool):
|
@@ -380,14 +392,13 @@ def get_dropdown_choices(info_dict):
|
|
380 |
return [f"{key}: {value}" for key, value in info_dict.items()]
|
381 |
|
382 |
# Gradio interface
|
383 |
-
with gr.Blocks(theme="Hev832/Applio", css=css) as demo:
|
384 |
with gr.Tab("Welcome"):
|
385 |
gr.Markdown(
|
386 |
"""
|
387 |
-
<img src="https://cdn-uploads.huggingface.co/production/uploads/64740cf7485a7c8e1bd51ac9/
|
388 |
-
|
389 |
|
390 |
-
# 🎨 Underground
|
391 |
|
392 |
## Accelerate Your Creative Workflow with Intelligent Image Analysis
|
393 |
|
@@ -401,8 +412,16 @@ with gr.Blocks(theme="Hev832/Applio", css=css) as demo:
|
|
401 |
4. **Generate and Iterate**: Click 'Caption' to analyze your image and use the results to inspire new creations.
|
402 |
"""
|
403 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
404 |
|
405 |
-
with gr.Tab("Caption Captain"):
|
406 |
with gr.Accordion("How to Use Caption Captain", open=False):
|
407 |
gr.Markdown("""
|
408 |
# How to Use Caption Captain
|
|
|
10 |
import os
|
11 |
import torchvision.transforms.functional as TVF
|
12 |
|
13 |
+
from dotenv import load_dotenv
|
14 |
+
|
15 |
+
# Load environment variables from .env file
|
16 |
+
load_dotenv()
|
17 |
+
|
18 |
+
USERNAME = os.getenv("USERNAME")
|
19 |
+
PASSWORD = os.getenv("PASSWORD")
|
20 |
|
21 |
CLIP_PATH = "google/siglip-so400m-patch14-384"
|
22 |
MODEL_PATH = "meta-llama/Meta-Llama-3.1-8B"
|
|
|
45 |
|
46 |
HF_TOKEN = os.environ.get("HF_TOKEN", None)
|
47 |
|
48 |
+
def login(username, password):
|
49 |
+
if username == USERNAME and password == PASSWORD:
|
50 |
+
return gr.update(visible=True), gr.update(visible=False), gr.update(visible=False), gr.update(value="Login successful! You can now access the QR Code Art Generator tab.", visible=True)
|
51 |
+
else:
|
52 |
+
return gr.update(visible=False), gr.update(visible=True), gr.update(visible=True), gr.update(value="Invalid username or password. Please try again.", visible=True)
|
53 |
|
54 |
class ImageAdapter(nn.Module):
|
55 |
def __init__(self, input_features: int, output_features: int, ln1: bool, pos_emb: bool, num_image_tokens: int, deep_extract: bool):
|
|
|
392 |
return [f"{key}: {value}" for key, value in info_dict.items()]
|
393 |
|
394 |
# Gradio interface
|
395 |
+
with gr.Blocks(theme="Hev832/Applio", css=css, fill_width=True, fill_height=True) as demo:
|
396 |
with gr.Tab("Welcome"):
|
397 |
gr.Markdown(
|
398 |
"""
|
399 |
+
<img src="https://cdn-uploads.huggingface.co/production/uploads/64740cf7485a7c8e1bd51ac9/LVZnwLV43UUvKu3HORqSs.webp" alt="UDG" class="centered-image" width="250" style="max-width: 100%; height: auto;">
|
|
|
400 |
|
401 |
+
# 🎨 Underground Digital's Caption Captain: AI-Powered Art Inspiration
|
402 |
|
403 |
## Accelerate Your Creative Workflow with Intelligent Image Analysis
|
404 |
|
|
|
412 |
4. **Generate and Iterate**: Click 'Caption' to analyze your image and use the results to inspire new creations.
|
413 |
"""
|
414 |
)
|
415 |
+
|
416 |
+
with gr.Row():
|
417 |
+
username = gr.Textbox(label="Username", placeholder="Enter your username", value="ugd")
|
418 |
+
with gr.Row():
|
419 |
+
password = gr.Textbox(label="Password", type="password", placeholder="Enter your password", value="ugd!")
|
420 |
+
with gr.Row():
|
421 |
+
login_button = gr.Button("Login", size="sm")
|
422 |
+
login_message = gr.Markdown(visible=False)
|
423 |
|
424 |
+
with gr.Tab("Caption Captain") as app_container:
|
425 |
with gr.Accordion("How to Use Caption Captain", open=False):
|
426 |
gr.Markdown("""
|
427 |
# How to Use Caption Captain
|