dreibh commited on
Commit
7f46aae
·
verified ·
1 Parent(s): 838df6a

Some improvements.

Browse files
Files changed (1) hide show
  1. app.py +9 -11
app.py CHANGED
@@ -224,13 +224,14 @@ def download(request: gradio.Request,
224
  else:
225
  outputLeads = [ 'I', 'II', 'V1', 'V2', 'V3', 'V4' , 'V5' , 'V6' ]
226
 
227
- deepfakeecg.dataToPDF(ecgResult, ecgType, outputLeads, fileName,
228
- Sessions[request.session_hash].Selected + 1,
229
- outputFormat)
230
 
231
  log(f'Session "{request.session_hash}": Download PDF file {fileName}')
232
  return fileName
233
 
 
 
234
 
235
  # ###### Download CSV #######################################################
236
  def downloadCSV(request: gradio.Request) -> pathlib.Path:
@@ -426,12 +427,9 @@ with gradio.Blocks(css = css, theme = gradio.themes.Glass(secondary_hue=gradio.t
426
  # gradio.Markdown('## Output')
427
 
428
  with gradio.Row(): # height = '24vh', min_height = '24vh', max_height = '24vh'):
429
- analysisOutput = gradio.Plot(label = 'Analysis')
430
-
431
- with gradio.Row(): # height = '24vh', min_height = '24vh', max_height = '24vh'):
432
- outputGallery = gradio.Gallery(label = 'ECG',
433
  columns = 8,
434
- rows = 1,
435
  height = 'auto',
436
  object_fit = 'contain',
437
  show_label = True,
@@ -439,6 +437,9 @@ with gradio.Blocks(css = css, theme = gradio.themes.Glass(secondary_hue=gradio.t
439
  preview = False
440
  )
441
 
 
 
 
442
  # ====== Add click event handling for "Generate" button ==================
443
  buttonGenerate.click(predict,
444
  inputs = [ sliderNumberOfECGs,
@@ -457,19 +458,16 @@ with gradio.Blocks(css = css, theme = gradio.themes.Glass(secondary_hue=gradio.t
457
  # ====== Add click event handling for download buttons ===================
458
  # Using hidden button and JavaScript, to generate download file on-the-fly:
459
  # https://github.com/gradio-app/gradio/issues/9230#issuecomment-2323771634
460
- buttonCSV.click(downloadCSV)
461
  buttonCSV.click(fn = downloadCSV,
462
  inputs = None,
463
  outputs = [ buttonCSV_hidden ]).then(
464
  fn = None, inputs = None, outputs = None,
465
  js = "() => document.querySelector('#download_csv_hidden').click()")
466
- buttonPDF.click(downloadPDF)
467
  buttonPDF.click(fn = downloadPDF,
468
  inputs = None,
469
  outputs = [ buttonPDF_hidden ]).then(
470
  fn = None, inputs = None, outputs = None,
471
  js = "() => document.querySelector('#download_pdf_hidden').click()")
472
- buttonPDFwAnalysis.click(downloadPDFwithAnalysis)
473
  buttonPDFwAnalysis.click(fn = downloadPDFwithAnalysis,
474
  inputs = None,
475
  outputs = [ buttonPDFwAnalysis_hidden ]).then(
 
224
  else:
225
  outputLeads = [ 'I', 'II', 'V1', 'V2', 'V3', 'V4' , 'V5' , 'V6' ]
226
 
227
+ deepfakeecg.dataToPDF(ecgResult, ecgType, outputLeads, fileName, outputFormat,
228
+ Sessions[request.session_hash].Selected + 1)
 
229
 
230
  log(f'Session "{request.session_hash}": Download PDF file {fileName}')
231
  return fileName
232
 
233
+ return None
234
+
235
 
236
  # ###### Download CSV #######################################################
237
  def downloadCSV(request: gradio.Request) -> pathlib.Path:
 
427
  # gradio.Markdown('## Output')
428
 
429
  with gradio.Row(): # height = '24vh', min_height = '24vh', max_height = '24vh'):
430
+ outputGallery = gradio.Gallery(label = 'Generated ECGs',
 
 
 
431
  columns = 8,
432
+ # rows = 1,
433
  height = 'auto',
434
  object_fit = 'contain',
435
  show_label = True,
 
437
  preview = False
438
  )
439
 
440
+ with gradio.Row(): # height = '24vh', min_height = '24vh', max_height = '24vh'):
441
+ analysisOutput = gradio.Plot(label = 'Analysis')
442
+
443
  # ====== Add click event handling for "Generate" button ==================
444
  buttonGenerate.click(predict,
445
  inputs = [ sliderNumberOfECGs,
 
458
  # ====== Add click event handling for download buttons ===================
459
  # Using hidden button and JavaScript, to generate download file on-the-fly:
460
  # https://github.com/gradio-app/gradio/issues/9230#issuecomment-2323771634
 
461
  buttonCSV.click(fn = downloadCSV,
462
  inputs = None,
463
  outputs = [ buttonCSV_hidden ]).then(
464
  fn = None, inputs = None, outputs = None,
465
  js = "() => document.querySelector('#download_csv_hidden').click()")
 
466
  buttonPDF.click(fn = downloadPDF,
467
  inputs = None,
468
  outputs = [ buttonPDF_hidden ]).then(
469
  fn = None, inputs = None, outputs = None,
470
  js = "() => document.querySelector('#download_pdf_hidden').click()")
 
471
  buttonPDFwAnalysis.click(fn = downloadPDFwithAnalysis,
472
  inputs = None,
473
  outputs = [ buttonPDFwAnalysis_hidden ]).then(