Update app.py
Browse files
app.py
CHANGED
@@ -5,6 +5,27 @@ from PIL import Image
|
|
5 |
from transformers import AutoTokenizer, AutoModel
|
6 |
import torch
|
7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
# Function to get image embeddings using ViT
|
9 |
def get_image_embeddings(image_path, model_name='google/vit-base-patch16-224'):
|
10 |
feature_extractor = ViTFeatureExtractor.from_pretrained(model_name)
|
@@ -64,12 +85,11 @@ def process_pdf_and_generate_response(pdf_file):
|
|
64 |
response = "Response based on the processed PDF"
|
65 |
return response
|
66 |
|
67 |
-
# Gradio interface
|
68 |
iface = gr.Interface(
|
69 |
fn=process_pdf_and_generate_response,
|
70 |
-
inputs=
|
71 |
-
|
72 |
-
title="Talk2Deck - Interact with your PDFs",
|
73 |
description="Upload a PDF and receive insights based on its content."
|
74 |
)
|
75 |
|
|
|
5 |
from transformers import AutoTokenizer, AutoModel
|
6 |
import torch
|
7 |
|
8 |
+
|
9 |
+
|
10 |
+
# Define custom CSS styles
|
11 |
+
button_style = gr.style(
|
12 |
+
padding="10px 20px",
|
13 |
+
background="#007BFF",
|
14 |
+
color="white",
|
15 |
+
border="none",
|
16 |
+
cursor="pointer",
|
17 |
+
font_size="16px",
|
18 |
+
margin="10px"
|
19 |
+
)
|
20 |
+
|
21 |
+
# Define layout with custom styles
|
22 |
+
layout = [
|
23 |
+
gr.Row([gr.File(label="Upload PDF", type="file")]),
|
24 |
+
gr.Row([gr.Button("Generate Insights", type="submit", style=button_style)]),
|
25 |
+
gr.Row([gr.Textbox("Placeholder for PDF insights", label="Insights", type="text")])
|
26 |
+
]
|
27 |
+
|
28 |
+
|
29 |
# Function to get image embeddings using ViT
|
30 |
def get_image_embeddings(image_path, model_name='google/vit-base-patch16-224'):
|
31 |
feature_extractor = ViTFeatureExtractor.from_pretrained(model_name)
|
|
|
85 |
response = "Response based on the processed PDF"
|
86 |
return response
|
87 |
|
88 |
+
# Gradio interface with customized layout
|
89 |
iface = gr.Interface(
|
90 |
fn=process_pdf_and_generate_response,
|
91 |
+
inputs=layout,
|
92 |
+
title="pdf-chatbot",
|
|
|
93 |
description="Upload a PDF and receive insights based on its content."
|
94 |
)
|
95 |
|