Spaces:
Runtime error
Runtime error
alitavanaali
commited on
Commit
·
0f298e9
1
Parent(s):
a518fb8
Update app.py
Browse files
app.py
CHANGED
@@ -280,7 +280,9 @@ def createDataframe(predictions, words):
|
|
280 |
result1, result2 = zip(*sorted(zip(predictions, words), key=lambda x: x[0]))
|
281 |
d = {'key':result1,'value':result2}
|
282 |
df = pd.DataFrame(d)
|
283 |
-
|
|
|
|
|
284 |
|
285 |
def isInside(w, z):
|
286 |
# return True if w is inside z, if z is inside w return false
|
@@ -344,7 +346,8 @@ def mergeImageVertical(a):
|
|
344 |
return imgs_comb
|
345 |
|
346 |
def completepreprocess(pdffile):
|
347 |
-
|
|
|
348 |
a=[]
|
349 |
doc = fitz.open(pdffile)
|
350 |
for i in range(0,len(doc)):
|
@@ -366,11 +369,12 @@ def completepreprocess(pdffile):
|
|
366 |
pred_list.append(iob_to_label(number))
|
367 |
_bbox, _preds, _words = process_form(pred_list, words, bbox)
|
368 |
print('page: ' + str(i) + ' ' + str(len(_preds))+ ' ' + str(len(_words)))
|
369 |
-
|
370 |
-
|
|
|
371 |
|
372 |
im2=mergeImageVertical(a)
|
373 |
-
return im2,
|
374 |
|
375 |
|
376 |
title = "Interactive demo: Music Information Extraction model"
|
@@ -384,7 +388,7 @@ iface = gr.Interface(fn=completepreprocess,
|
|
384 |
#inputs=gr.inputs.Image(type="pil",optional=True,label="upload file"),
|
385 |
inputs=gr.File(label="PDF"),
|
386 |
#inputs=gr.inputs.Image(type="pil")
|
387 |
-
outputs=[gr.outputs.Image(type="pil", label="annotated image"),"dataframe"] ,
|
388 |
title=title,
|
389 |
description=description,
|
390 |
examples=examples,
|
|
|
280 |
result1, result2 = zip(*sorted(zip(predictions, words), key=lambda x: x[0]))
|
281 |
d = {'key':result1,'value':result2}
|
282 |
df = pd.DataFrame(d)
|
283 |
+
df1 = df[df['key'] != 'lyrics']
|
284 |
+
df2 = df[df['key'] == 'lyrics']
|
285 |
+
return df1, df2
|
286 |
|
287 |
def isInside(w, z):
|
288 |
# return True if w is inside z, if z is inside w return false
|
|
|
346 |
return imgs_comb
|
347 |
|
348 |
def completepreprocess(pdffile):
|
349 |
+
dfOne = pd.DataFrame()
|
350 |
+
dfTwo = pd.DataFrame()
|
351 |
a=[]
|
352 |
doc = fitz.open(pdffile)
|
353 |
for i in range(0,len(doc)):
|
|
|
369 |
pred_list.append(iob_to_label(number))
|
370 |
_bbox, _preds, _words = process_form(pred_list, words, bbox)
|
371 |
print('page: ' + str(i) + ' ' + str(len(_preds))+ ' ' + str(len(_words)))
|
372 |
+
df1, df2 = createDataframe(_preds, _words)
|
373 |
+
dfOne=dfOne.append(df1)
|
374 |
+
dfTwo=dfOne.append(df2)
|
375 |
|
376 |
im2=mergeImageVertical(a)
|
377 |
+
return im2,dfOne,dfTwo
|
378 |
|
379 |
|
380 |
title = "Interactive demo: Music Information Extraction model"
|
|
|
388 |
#inputs=gr.inputs.Image(type="pil",optional=True,label="upload file"),
|
389 |
inputs=gr.File(label="PDF"),
|
390 |
#inputs=gr.inputs.Image(type="pil")
|
391 |
+
outputs=[gr.outputs.Image(type="pil", label="annotated image"),"dataframe", "dataframe"] ,
|
392 |
title=title,
|
393 |
description=description,
|
394 |
examples=examples,
|