Karthikeyan
commited on
Commit
·
f915301
1
Parent(s):
ee4bd84
Update app.py
Browse files
app.py
CHANGED
@@ -20,7 +20,7 @@ import re
|
|
20 |
|
21 |
|
22 |
# Create and Declare Global Varibale "result"
|
23 |
-
|
24 |
|
25 |
class ChemicalIdentifier:
|
26 |
|
@@ -209,7 +209,7 @@ class ChemicalIdentifier:
|
|
209 |
|
210 |
|
211 |
file_paths = [single_file_path.name for single_file_path in file_paths]
|
212 |
-
|
213 |
for file_obj in file_paths:
|
214 |
|
215 |
loader = UnstructuredFileLoader(file_obj, strategy="fast")
|
@@ -221,11 +221,11 @@ class ChemicalIdentifier:
|
|
221 |
knowledge_base = self.create_knowledge_base(docs)
|
222 |
state = {"knowledge_base": knowledge_base}
|
223 |
pdf_name = os.path.basename(file_obj)
|
224 |
-
global results
|
225 |
final_ans = self.get_chemicals_for_file(state)
|
226 |
-
|
227 |
-
|
228 |
# Return a tuple containing the file name and the knowledge base
|
|
|
229 |
return results
|
230 |
|
231 |
def get_final_result(self,urls,file_paths,state,progress=gr.Progress()):
|
@@ -252,8 +252,8 @@ class ChemicalIdentifier:
|
|
252 |
Starts the Gradio interface for chemical identification.
|
253 |
"""
|
254 |
|
255 |
-
with gr.Blocks(css="style.css",theme='karthikeyan-adople/hudsonhayes-
|
256 |
-
gr.HTML("""<center><img src="https://hudsonandhayes.co.uk/wp-content/uploads/2023/01/Group-479.svg" height="110px" width="280px"></
|
257 |
state = gr.State(self.get_empty_state())
|
258 |
gr.HTML("""<center><h1 style="color:#fff">Chemical Identifier</h1></center>""")
|
259 |
|
|
|
20 |
|
21 |
|
22 |
# Create and Declare Global Varibale "result"
|
23 |
+
|
24 |
|
25 |
class ChemicalIdentifier:
|
26 |
|
|
|
209 |
|
210 |
|
211 |
file_paths = [single_file_path.name for single_file_path in file_paths]
|
212 |
+
collection_of_results = []
|
213 |
for file_obj in file_paths:
|
214 |
|
215 |
loader = UnstructuredFileLoader(file_obj, strategy="fast")
|
|
|
221 |
knowledge_base = self.create_knowledge_base(docs)
|
222 |
state = {"knowledge_base": knowledge_base}
|
223 |
pdf_name = os.path.basename(file_obj)
|
|
|
224 |
final_ans = self.get_chemicals_for_file(state)
|
225 |
+
response = pdf_name+"\n"+final_ans+"\n\n"
|
226 |
+
collection_of_results.append(response)
|
227 |
# Return a tuple containing the file name and the knowledge base
|
228 |
+
results = "".join(collection_of_results)
|
229 |
return results
|
230 |
|
231 |
def get_final_result(self,urls,file_paths,state,progress=gr.Progress()):
|
|
|
252 |
Starts the Gradio interface for chemical identification.
|
253 |
"""
|
254 |
|
255 |
+
with gr.Blocks(css="style.css",theme='karthikeyan-adople/hudsonhayes-gray') as demo:
|
256 |
+
gr.HTML("""<h1 style='background-color:rgb(0,1,36); text-align:center;'><img src="https://hudsonandhayes.co.uk/wp-content/uploads/2023/01/Group-479.svg" height="110px" width="280px"></h1>""")
|
257 |
state = gr.State(self.get_empty_state())
|
258 |
gr.HTML("""<center><h1 style="color:#fff">Chemical Identifier</h1></center>""")
|
259 |
|