Spaces:
Running
Running
Merge branch 'main' of https://huggingface.co/spaces/MsChabane/SmartDoc
Browse files- main.py +25 -25
- requirements.txt +2 -1
- templates/index.html +1 -1
main.py
CHANGED
@@ -51,7 +51,7 @@ def caption(file:UploadFile=File(...)):
|
|
51 |
if extension not in Supported_extensions:
|
52 |
return {"error": "Unsupported file type"}
|
53 |
image = Image.open(file.file)
|
54 |
-
interpreter = pipeline("image-to-text", model="Salesforce/blip-image-captioning-
|
55 |
caption = interpreter(image)
|
56 |
return {"caption": caption[0]['generated_text']}
|
57 |
|
@@ -86,30 +86,30 @@ def plot(prompt:str,file:UploadFile=File(...)):
|
|
86 |
return {"error": "Unsupported file type"}
|
87 |
df = pd.read_excel(file.file)
|
88 |
message = f"""
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
"""
|
114 |
generator = pipeline("text-generation", model="deepseek-ai/deepseek-coder-1.3b-instruct", device_map="auto")
|
115 |
output = generator(message, max_length=1000)
|
|
|
51 |
if extension not in Supported_extensions:
|
52 |
return {"error": "Unsupported file type"}
|
53 |
image = Image.open(file.file)
|
54 |
+
interpreter = pipeline("image-to-text", model="Salesforce/blip-image-captioning-large")
|
55 |
caption = interpreter(image)
|
56 |
return {"caption": caption[0]['generated_text']}
|
57 |
|
|
|
86 |
return {"error": "Unsupported file type"}
|
87 |
df = pd.read_excel(file.file)
|
88 |
message = f"""
|
89 |
+
You are a helpful assistant that helps users write Python code.
|
90 |
+
## Requirements:
|
91 |
+
-you will be given a task and you will write the code to solve the task.
|
92 |
+
-you have a dataset called **df** contains the following information:
|
93 |
+
df.columns:{df.columns.to_list()}
|
94 |
+
df.dtypes:{df.dtypes.to_dict()}
|
95 |
+
|
96 |
+
-you have to write the code to solve the task using the dataset df.
|
97 |
+
-you can use pandas to manipulate the dataframe.
|
98 |
+
-you can use matplotlib to plot the data.
|
99 |
+
-you can use seaborn to plot the data.
|
100 |
+
-don't use print or input statements in the code.
|
101 |
+
-don't use any other libraries except pandas, matplotlib, seaborn.
|
102 |
+
-don't use any other functions except the ones provided in the libraries.
|
103 |
+
-don't write the code for the dataframe creation.
|
104 |
+
-exclude plt.show() from the code.
|
105 |
+
-you have to write the code in a markdown code block.
|
106 |
+
-make sure that the type of the chart is compatible with the dtypes of the columns
|
107 |
+
-use only the column specified in the task.
|
108 |
+
-you have to extract the column names and the plot type from the prompt bellow and use them in the code.
|
109 |
+
-if the user task is not clear or there is an error like the column names are not in the dataframe, raise an
|
110 |
+
error.
|
111 |
+
|
112 |
+
##Prompt: {prompt}.
|
113 |
"""
|
114 |
generator = pipeline("text-generation", model="deepseek-ai/deepseek-coder-1.3b-instruct", device_map="auto")
|
115 |
output = generator(message, max_length=1000)
|
requirements.txt
CHANGED
@@ -8,4 +8,5 @@ PyMuPDF
|
|
8 |
matplotlib
|
9 |
transformers
|
10 |
seaborn
|
11 |
-
jinja2
|
|
|
|
8 |
matplotlib
|
9 |
transformers
|
10 |
seaborn
|
11 |
+
jinja2
|
12 |
+
torch
|
templates/index.html
CHANGED
@@ -6,7 +6,7 @@
|
|
6 |
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
7 |
<title>SmartDoc AI</title>
|
8 |
<link rel="stylesheet" href="static/styles/index.css" />
|
9 |
-
<link rel="stylesheet" href="
|
10 |
<link rel="stylesheet" href="static/styles/notification.css" />
|
11 |
</head>
|
12 |
|
|
|
6 |
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
7 |
<title>SmartDoc AI</title>
|
8 |
<link rel="stylesheet" href="static/styles/index.css" />
|
9 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css" />
|
10 |
<link rel="stylesheet" href="static/styles/notification.css" />
|
11 |
</head>
|
12 |
|