Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -110,20 +110,20 @@ def _inference_classifier(text):
|
|
| 110 |
|
| 111 |
return sigmoid(ort_outs[0])
|
| 112 |
|
| 113 |
-
def inference(
|
| 114 |
input_batch_content = []
|
| 115 |
-
if file_in.name is not "":
|
| 116 |
-
print("[i] Input is file:",file_in.name)
|
| 117 |
-
dft = pd.read_csv(
|
| 118 |
-
file_in.name,
|
| 119 |
-
compression=dict(method='zip')
|
| 120 |
-
)
|
| 121 |
-
assert file_col_name in dft.columns, "Indicated col_name not found in file"
|
| 122 |
-
input_batch_r = dft[file_col_name].values.tolist()
|
| 123 |
-
else:
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
|
| 128 |
print("[i] Input size:",len(input_batch_r))
|
| 129 |
|
|
@@ -177,7 +177,7 @@ API input parameters:
|
|
| 177 |
- `limit_companies`: integer. Number of found relevant companies to report.
|
| 178 |
|
| 179 |
"""
|
| 180 |
-
examples = [[
|
| 181 |
['https://www.bbc.com/news/business-62747401'],
|
| 182 |
['https://www.bbc.com/news/technology-62744858'],
|
| 183 |
['https://www.bbc.com/news/science-environment-62758811'],
|
|
@@ -187,9 +187,7 @@ examples = [["","",[['https://www.bbc.com/news/uk-62732447'],
|
|
| 187 |
['https://www.bbc.com/news/business-62728621'],
|
| 188 |
['https://www.bbc.com/news/science-environment-62680423']],'url',False,5]]
|
| 189 |
demo = gr.Interface(fn=inference,
|
| 190 |
-
inputs=[gr.
|
| 191 |
-
gr.Textbox(label='If csv, column header name that contains the relevant data:'),
|
| 192 |
-
gr.Dataframe(label='input batch', col_count=1, datatype='str', type='array', wrap=True),
|
| 193 |
gr.Dropdown(label='data type', choices=['text','url'], type='index', value='url'),
|
| 194 |
gr.Checkbox(label='if url parse cached in archive.org'),
|
| 195 |
gr.Slider(minimum=1, maximum=10, step=1, label='Limit NER output', value=5)],
|
|
|
|
| 110 |
|
| 111 |
return sigmoid(ort_outs[0])
|
| 112 |
|
| 113 |
+
def inference(input_batch,isurl,use_archive,limit_companies=10):
|
| 114 |
input_batch_content = []
|
| 115 |
+
# if file_in.name is not "":
|
| 116 |
+
# print("[i] Input is file:",file_in.name)
|
| 117 |
+
# dft = pd.read_csv(
|
| 118 |
+
# file_in.name,
|
| 119 |
+
# compression=dict(method='zip')
|
| 120 |
+
# )
|
| 121 |
+
# assert file_col_name in dft.columns, "Indicated col_name not found in file"
|
| 122 |
+
# input_batch_r = dft[file_col_name].values.tolist()
|
| 123 |
+
# else:
|
| 124 |
+
print("[i] Input is list")
|
| 125 |
+
assert len(input_batch) > 0, "input_batch array is empty"
|
| 126 |
+
input_batch_r = input_batch
|
| 127 |
|
| 128 |
print("[i] Input size:",len(input_batch_r))
|
| 129 |
|
|
|
|
| 177 |
- `limit_companies`: integer. Number of found relevant companies to report.
|
| 178 |
|
| 179 |
"""
|
| 180 |
+
examples = [[ [['https://www.bbc.com/news/uk-62732447'],
|
| 181 |
['https://www.bbc.com/news/business-62747401'],
|
| 182 |
['https://www.bbc.com/news/technology-62744858'],
|
| 183 |
['https://www.bbc.com/news/science-environment-62758811'],
|
|
|
|
| 187 |
['https://www.bbc.com/news/business-62728621'],
|
| 188 |
['https://www.bbc.com/news/science-environment-62680423']],'url',False,5]]
|
| 189 |
demo = gr.Interface(fn=inference,
|
| 190 |
+
inputs=[gr.Dataframe(label='input batch', col_count=1, datatype='str', type='array', wrap=True),
|
|
|
|
|
|
|
| 191 |
gr.Dropdown(label='data type', choices=['text','url'], type='index', value='url'),
|
| 192 |
gr.Checkbox(label='if url parse cached in archive.org'),
|
| 193 |
gr.Slider(minimum=1, maximum=10, step=1, label='Limit NER output', value=5)],
|