Add application file
Browse files
app.py
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 2 |
from PIL import Image
|
| 3 |
-
import gradio as gr
|
| 4 |
import numpy as np
|
| 5 |
|
| 6 |
# Load the model and tokenizer
|
|
@@ -23,9 +28,21 @@ def analyze_image_direct(image, question):
|
|
| 23 |
|
| 24 |
return answer
|
| 25 |
|
| 26 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
iface = gr.Interface(fn=analyze_image_direct,
|
| 28 |
-
theme=
|
| 29 |
inputs=[gr.Image(type="pil"), gr.Textbox(lines=2, placeholder="Enter your question here...")],
|
| 30 |
outputs='text',
|
| 31 |
title="Direct Image Question Answering",
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
from typing import Iterable
|
| 3 |
+
import gradio as gr
|
| 4 |
+
from gradio.themes.base import Base
|
| 5 |
+
from gradio.themes.utils import colors, fonts, sizes
|
| 6 |
+
import time
|
| 7 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 8 |
from PIL import Image
|
|
|
|
| 9 |
import numpy as np
|
| 10 |
|
| 11 |
# Load the model and tokenizer
|
|
|
|
| 28 |
|
| 29 |
return answer
|
| 30 |
|
| 31 |
+
# Define a custom theme with purple color scheme
|
| 32 |
+
class PurpleTheme(Base):
|
| 33 |
+
primary_color = "#9b59b6" # Example purple shade
|
| 34 |
+
primary_color_dark = "#8e44ad" # Darker purple
|
| 35 |
+
text_color = "#FFFFFF" # White text for contrast
|
| 36 |
+
background_color = "#5B2C6F" # Deep purple background
|
| 37 |
+
secondary_background_color = "#7D3C98" # Lighter purple for secondary elements
|
| 38 |
+
font = "Arial"
|
| 39 |
+
|
| 40 |
+
# Create a custom theme instance
|
| 41 |
+
purple_theme = PurpleTheme()
|
| 42 |
+
|
| 43 |
+
# Create Gradio interface with the custom theme
|
| 44 |
iface = gr.Interface(fn=analyze_image_direct,
|
| 45 |
+
theme=purple_theme,
|
| 46 |
inputs=[gr.Image(type="pil"), gr.Textbox(lines=2, placeholder="Enter your question here...")],
|
| 47 |
outputs='text',
|
| 48 |
title="Direct Image Question Answering",
|