Spaces:
Running
Running
chabane
commited on
Commit
·
9846280
1
Parent(s):
a9fa82a
add images and modify the main file
Browse files- main.py +10 -6
- static/assets/balls-1950487_1280.jpg +3 -0
- static/assets/graph-4737109_1280.jpg +3 -0
- static/assets/journal-2850091_1280.jpg +3 -0
- static/assets/smart-home-3317440_1280.jpg +3 -0
- static/assets/technology-3435575_1280.jpg +3 -0
- static/scripts/data-visualisation.js +5 -4
- static/styles/index.css +11 -3
- templates/index.html +8 -5
main.py
CHANGED
|
@@ -24,7 +24,7 @@ from transformers import (
|
|
| 24 |
AutoModelForCausalLM,pipeline
|
| 25 |
)
|
| 26 |
|
| 27 |
-
|
| 28 |
try:
|
| 29 |
print("[Info] installing Salesforce/blip-image-captioning-base ....")
|
| 30 |
blip_dir = "./models/blip-base-tf"
|
|
@@ -35,7 +35,7 @@ except Exception as exp:
|
|
| 35 |
print("Can't load the model Salesforce/blip-image-captioning-base")
|
| 36 |
print(f"[Error] {str(exp)}")
|
| 37 |
|
| 38 |
-
|
| 39 |
try:
|
| 40 |
print("[Info] installing facebook/bart-large-cnn ....")
|
| 41 |
bart_dir = "./models/bart-large-cnn"
|
|
@@ -48,7 +48,6 @@ except Exception as exp:
|
|
| 48 |
print("Can't load the model facebook/bart-large-cnn")
|
| 49 |
print(f"[Error] {str(exp)}")
|
| 50 |
|
| 51 |
-
# === 3. Load DeepSeek Coder (PyTorch with trust_remote_code) ===
|
| 52 |
try:
|
| 53 |
print("[Info] installing deepseek-ai/deepseek-coder-1.3b-instruct ")
|
| 54 |
deepseek_dir = "./models/deepseek-coder"
|
|
@@ -112,10 +111,11 @@ def interpret(file_img:UploadFile=File(...)):
|
|
| 112 |
def summerzation(file:UploadFile=File(...)):
|
| 113 |
try:
|
| 114 |
extension = file.filename.split(".")[-1]
|
| 115 |
-
supported_ext=["pdf","
|
| 116 |
if extension not in supported_ext :
|
| 117 |
return JSONResponse(content={"error": "Unsupported file type"},status_code=400)
|
| 118 |
file_bytes = file.file.read()
|
|
|
|
| 119 |
if len(file_bytes) > MAX_SIZE :
|
| 120 |
return JSONResponse(content={"error": "too large file "},status_code=400)
|
| 121 |
if extension == "pdf":
|
|
@@ -151,8 +151,10 @@ def plot(user_need:str,file:UploadFile=File(...)):
|
|
| 151 |
Supported_extensions = ["xlsx","xls"]
|
| 152 |
if extension not in Supported_extensions:
|
| 153 |
return JSONResponse(content={"error": "Unsupported file type"},status_code=400)
|
| 154 |
-
|
| 155 |
-
|
|
|
|
|
|
|
| 156 |
|
| 157 |
message = f"""
|
| 158 |
You are a helpful assistant that helps users write Python code.
|
|
@@ -201,11 +203,13 @@ error.
|
|
| 201 |
plt.savefig(buf, format='png')
|
| 202 |
buf.seek(0)
|
| 203 |
base64_image = base64.b64encode(buf.getvalue()).decode('utf-8')
|
|
|
|
| 204 |
return JSONResponse(content={"plot": f"data:image/png;base64,{base64_image}",'code':code},status_code=200)
|
| 205 |
except Exception as e:
|
| 206 |
print(e)
|
| 207 |
return JSONResponse(content={"error": str(e) },status_code=500)
|
| 208 |
except Exception as exp:
|
|
|
|
| 209 |
return JSONResponse(content={"error":"Internel Server Error:"+str(exp)} ,status_code=500)
|
| 210 |
|
| 211 |
|
|
|
|
| 24 |
AutoModelForCausalLM,pipeline
|
| 25 |
)
|
| 26 |
|
| 27 |
+
|
| 28 |
try:
|
| 29 |
print("[Info] installing Salesforce/blip-image-captioning-base ....")
|
| 30 |
blip_dir = "./models/blip-base-tf"
|
|
|
|
| 35 |
print("Can't load the model Salesforce/blip-image-captioning-base")
|
| 36 |
print(f"[Error] {str(exp)}")
|
| 37 |
|
| 38 |
+
|
| 39 |
try:
|
| 40 |
print("[Info] installing facebook/bart-large-cnn ....")
|
| 41 |
bart_dir = "./models/bart-large-cnn"
|
|
|
|
| 48 |
print("Can't load the model facebook/bart-large-cnn")
|
| 49 |
print(f"[Error] {str(exp)}")
|
| 50 |
|
|
|
|
| 51 |
try:
|
| 52 |
print("[Info] installing deepseek-ai/deepseek-coder-1.3b-instruct ")
|
| 53 |
deepseek_dir = "./models/deepseek-coder"
|
|
|
|
| 111 |
def summerzation(file:UploadFile=File(...)):
|
| 112 |
try:
|
| 113 |
extension = file.filename.split(".")[-1]
|
| 114 |
+
supported_ext=["pdf","xlsx","docx","ppt"]
|
| 115 |
if extension not in supported_ext :
|
| 116 |
return JSONResponse(content={"error": "Unsupported file type"},status_code=400)
|
| 117 |
file_bytes = file.file.read()
|
| 118 |
+
|
| 119 |
if len(file_bytes) > MAX_SIZE :
|
| 120 |
return JSONResponse(content={"error": "too large file "},status_code=400)
|
| 121 |
if extension == "pdf":
|
|
|
|
| 151 |
Supported_extensions = ["xlsx","xls"]
|
| 152 |
if extension not in Supported_extensions:
|
| 153 |
return JSONResponse(content={"error": "Unsupported file type"},status_code=400)
|
| 154 |
+
file_bytes = file.read()
|
| 155 |
+
if len(file_bytes) > MAX_SIZE :
|
| 156 |
+
return JSONResponse(content={"error": "too large file "},status_code=400)
|
| 157 |
+
df = pd.read_excel(io=io.BytesIO(file_bytes))
|
| 158 |
|
| 159 |
message = f"""
|
| 160 |
You are a helpful assistant that helps users write Python code.
|
|
|
|
| 203 |
plt.savefig(buf, format='png')
|
| 204 |
buf.seek(0)
|
| 205 |
base64_image = base64.b64encode(buf.getvalue()).decode('utf-8')
|
| 206 |
+
|
| 207 |
return JSONResponse(content={"plot": f"data:image/png;base64,{base64_image}",'code':code},status_code=200)
|
| 208 |
except Exception as e:
|
| 209 |
print(e)
|
| 210 |
return JSONResponse(content={"error": str(e) },status_code=500)
|
| 211 |
except Exception as exp:
|
| 212 |
+
print(exp)
|
| 213 |
return JSONResponse(content={"error":"Internel Server Error:"+str(exp)} ,status_code=500)
|
| 214 |
|
| 215 |
|
static/assets/balls-1950487_1280.jpg
ADDED
|
Git LFS Details
|
static/assets/graph-4737109_1280.jpg
ADDED
|
Git LFS Details
|
static/assets/journal-2850091_1280.jpg
ADDED
|
Git LFS Details
|
static/assets/smart-home-3317440_1280.jpg
ADDED
|
Git LFS Details
|
static/assets/technology-3435575_1280.jpg
ADDED
|
Git LFS Details
|
static/scripts/data-visualisation.js
CHANGED
|
@@ -6,6 +6,7 @@ document.addEventListener("DOMContentLoaded", function () {
|
|
| 6 |
const loadingContainer = document.getElementById("loading-container");
|
| 7 |
const resultsSection = document.getElementById("results-section");
|
| 8 |
const img_chart = document.getElementById("results-chart");
|
|
|
|
| 9 |
const newVisualizationBtn = document.getElementById("new-visualization-btn");
|
| 10 |
const downloadChartBtn = document.getElementById("download-chart-btn");
|
| 11 |
const downloadCodeBtn = document.getElementById("download-code-btn");
|
|
@@ -46,8 +47,9 @@ document.addEventListener("DOMContentLoaded", function () {
|
|
| 46 |
showNotification("error", result.error);
|
| 47 |
return;
|
| 48 |
}
|
| 49 |
-
|
| 50 |
-
img_chart.src =
|
|
|
|
| 51 |
resultsSection.style.display = "block";
|
| 52 |
resultsSection.scrollIntoView({ behavior: "smooth" });
|
| 53 |
} catch (error) {
|
|
@@ -77,8 +79,7 @@ document.addEventListener("DOMContentLoaded", function () {
|
|
| 77 |
});
|
| 78 |
|
| 79 |
downloadCodeBtn.addEventListener("click", function () {
|
| 80 |
-
const
|
| 81 |
-
const blob = new Blob([codeContent], { type: "text/plain" });
|
| 82 |
const url = URL.createObjectURL(blob);
|
| 83 |
|
| 84 |
const a = document.createElement("a");
|
|
|
|
| 6 |
const loadingContainer = document.getElementById("loading-container");
|
| 7 |
const resultsSection = document.getElementById("results-section");
|
| 8 |
const img_chart = document.getElementById("results-chart");
|
| 9 |
+
const chart_code = document.getElementById("code-content");
|
| 10 |
const newVisualizationBtn = document.getElementById("new-visualization-btn");
|
| 11 |
const downloadChartBtn = document.getElementById("download-chart-btn");
|
| 12 |
const downloadCodeBtn = document.getElementById("download-code-btn");
|
|
|
|
| 47 |
showNotification("error", result.error);
|
| 48 |
return;
|
| 49 |
}
|
| 50 |
+
|
| 51 |
+
img_chart.src = result.plot;
|
| 52 |
+
chart_code.innerHTML = result.code;
|
| 53 |
resultsSection.style.display = "block";
|
| 54 |
resultsSection.scrollIntoView({ behavior: "smooth" });
|
| 55 |
} catch (error) {
|
|
|
|
| 79 |
});
|
| 80 |
|
| 81 |
downloadCodeBtn.addEventListener("click", function () {
|
| 82 |
+
const blob = new Blob([chart_code.innerText], { type: "text/plain" });
|
|
|
|
| 83 |
const url = URL.createObjectURL(blob);
|
| 84 |
|
| 85 |
const a = document.createElement("a");
|
static/styles/index.css
CHANGED
|
@@ -188,13 +188,13 @@ nav {
|
|
| 188 |
|
| 189 |
.animate {
|
| 190 |
animation: show linear;
|
| 191 |
-
animation-timeline: view(
|
| 192 |
}
|
| 193 |
|
| 194 |
@keyframes show {
|
| 195 |
from {
|
| 196 |
opacity: 0;
|
| 197 |
-
transform: translate(
|
| 198 |
}
|
| 199 |
|
| 200 |
to {
|
|
@@ -253,6 +253,9 @@ nav {
|
|
| 253 |
border: 1px solid var(--background-card);
|
| 254 |
box-shadow: var(--shadow);
|
| 255 |
transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
|
|
|
|
|
|
|
|
|
|
| 256 |
}
|
| 257 |
|
| 258 |
.function-card:hover {
|
|
@@ -286,10 +289,15 @@ nav {
|
|
| 286 |
color: var(--primary-color);
|
| 287 |
font-weight: 500;
|
| 288 |
transition: color 0.3s ease;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 289 |
}
|
| 290 |
|
| 291 |
.function-link:hover {
|
| 292 |
-
color: var(--
|
| 293 |
}
|
| 294 |
|
| 295 |
|
|
|
|
| 188 |
|
| 189 |
.animate {
|
| 190 |
animation: show linear;
|
| 191 |
+
animation-timeline: view(100% auto);
|
| 192 |
}
|
| 193 |
|
| 194 |
@keyframes show {
|
| 195 |
from {
|
| 196 |
opacity: 0;
|
| 197 |
+
transform: translate(100px) scale(0.1);
|
| 198 |
}
|
| 199 |
|
| 200 |
to {
|
|
|
|
| 253 |
border: 1px solid var(--background-card);
|
| 254 |
box-shadow: var(--shadow);
|
| 255 |
transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
|
| 256 |
+
display: flex;
|
| 257 |
+
flex-direction: column;
|
| 258 |
+
|
| 259 |
}
|
| 260 |
|
| 261 |
.function-card:hover {
|
|
|
|
| 289 |
color: var(--primary-color);
|
| 290 |
font-weight: 500;
|
| 291 |
transition: color 0.3s ease;
|
| 292 |
+
flex: 1;
|
| 293 |
+
display: flex;
|
| 294 |
+
justify-content: center;
|
| 295 |
+
align-items: flex-end;
|
| 296 |
+
|
| 297 |
}
|
| 298 |
|
| 299 |
.function-link:hover {
|
| 300 |
+
color: var(--highlight-color);
|
| 301 |
}
|
| 302 |
|
| 303 |
|
templates/index.html
CHANGED
|
@@ -33,7 +33,7 @@
|
|
| 33 |
</div>
|
| 34 |
</div>
|
| 35 |
<div class="hero-image">
|
| 36 |
-
<img src="/
|
| 37 |
</div>
|
| 38 |
</div>
|
| 39 |
</section>
|
|
@@ -46,7 +46,7 @@
|
|
| 46 |
</div>
|
| 47 |
<div class="about-content">
|
| 48 |
<div class="about-image">
|
| 49 |
-
<img src="/
|
| 50 |
</div>
|
| 51 |
<div class="about-text">
|
| 52 |
<h3>Intelligent Document Processing</h3>
|
|
@@ -71,7 +71,7 @@
|
|
| 71 |
<div class="functions-grid">
|
| 72 |
<div class="function-card animate">
|
| 73 |
<div class="function-icon">
|
| 74 |
-
<img src="/
|
| 75 |
</div>
|
| 76 |
<h3>Text Summarization</h3>
|
| 77 |
<p>Extract key points and generate concise summaries from lengthy documents, articles, and reports
|
|
@@ -81,7 +81,7 @@
|
|
| 81 |
|
| 82 |
<div class="function-card animate">
|
| 83 |
<div class="function-icon">
|
| 84 |
-
<img src="/
|
| 85 |
</div>
|
| 86 |
<h3>Image Interpretation</h3>
|
| 87 |
<p>Analyze charts, graphs, diagrams, and visual content within documents to extract meaningful data
|
|
@@ -91,12 +91,15 @@
|
|
| 91 |
|
| 92 |
<div class="function-card animate">
|
| 93 |
<div class="function-icon">
|
| 94 |
-
<img src="/
|
| 95 |
</div>
|
| 96 |
<h3>Data Visualization</h3>
|
| 97 |
<p>Transform complex data from your documents into clear, interactive visualizations that make
|
| 98 |
information easier to understand and share.</p>
|
|
|
|
|
|
|
| 99 |
<a href="/datavisualisation" class="function-link">Learn More →</a>
|
|
|
|
| 100 |
</div>
|
| 101 |
</div>
|
| 102 |
</div>
|
|
|
|
| 33 |
</div>
|
| 34 |
</div>
|
| 35 |
<div class="hero-image">
|
| 36 |
+
<img src="static/assets/smart-home-3317440_1280.jpg" alt="SmartDoc AI Dashboard Preview">
|
| 37 |
</div>
|
| 38 |
</div>
|
| 39 |
</section>
|
|
|
|
| 46 |
</div>
|
| 47 |
<div class="about-content">
|
| 48 |
<div class="about-image">
|
| 49 |
+
<img src="static/assets/technology-3435575_1280.jpg" alt="SmartDoc AI in action">
|
| 50 |
</div>
|
| 51 |
<div class="about-text">
|
| 52 |
<h3>Intelligent Document Processing</h3>
|
|
|
|
| 71 |
<div class="functions-grid">
|
| 72 |
<div class="function-card animate">
|
| 73 |
<div class="function-icon">
|
| 74 |
+
<img src="static/assets/journal-2850091_1280.jpg" alt="Text Summarization Icon">
|
| 75 |
</div>
|
| 76 |
<h3>Text Summarization</h3>
|
| 77 |
<p>Extract key points and generate concise summaries from lengthy documents, articles, and reports
|
|
|
|
| 81 |
|
| 82 |
<div class="function-card animate">
|
| 83 |
<div class="function-icon">
|
| 84 |
+
<img src="static/assets/balls-1950487_1280.jpg" alt="Image Interpretation Icon">
|
| 85 |
</div>
|
| 86 |
<h3>Image Interpretation</h3>
|
| 87 |
<p>Analyze charts, graphs, diagrams, and visual content within documents to extract meaningful data
|
|
|
|
| 91 |
|
| 92 |
<div class="function-card animate">
|
| 93 |
<div class="function-icon">
|
| 94 |
+
<img src="static/assets/graph-4737109_1280.jpg" alt="Data Visualization Icon">
|
| 95 |
</div>
|
| 96 |
<h3>Data Visualization</h3>
|
| 97 |
<p>Transform complex data from your documents into clear, interactive visualizations that make
|
| 98 |
information easier to understand and share.</p>
|
| 99 |
+
|
| 100 |
+
|
| 101 |
<a href="/datavisualisation" class="function-link">Learn More →</a>
|
| 102 |
+
|
| 103 |
</div>
|
| 104 |
</div>
|
| 105 |
</div>
|