ThomasSimonini HF staff commited on
Commit
a3fe4eb
1 Parent(s): 69d75a6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -6
app.py CHANGED
@@ -346,7 +346,8 @@ def generate_certificate(certificate_model, first_name, last_name):
346
  rgba = im
347
  rgb = Image.new('RGB', im.size, (255, 255, 255)) # white background
348
  rgb.paste(rgba, mask=rgba.split()[3]) # 3 is the alpha channel
349
- pdf_ = rgb.save("certificate.pdf", 'PDF', resolution=100.0)
 
350
  pdf = pdf_.filename
351
 
352
  return im, pdf
@@ -391,10 +392,11 @@ with gr.Blocks() as demo:
391
  last_name = gr.Textbox(placeholder="Doe", label="Your Last Name")
392
  #email = gr.Textbox(placeholder="jane.doe@gmail.com", label="Your Email (to receive your certificate)")
393
  check_progress_button = gr.Button(value="Check if I pass")
394
- output_text = gr.components.Textbox()
395
- output_pdf = gr.File()
396
- output_img = gr.components.Image(type="pil")
397
- output_dataframe = gr.components.Dataframe(headers=["Pass?", "Unit", "Environment", "Baseline", "Your best result", "Your best model id"], datatype=["markdown", "markdown", "markdown", "number", "number", "markdown", "bool"]) #value= certification(hf_username, first_name, last_name),
398
  check_progress_button.click(fn=certification, inputs=[hf_username, first_name, last_name], outputs=[output_text, output_pdf, output_img, output_dataframe])#[output1, output2])
399
-
 
 
 
 
 
400
  demo.launch(debug=True)
 
346
  rgba = im
347
  rgb = Image.new('RGB', im.size, (255, 255, 255)) # white background
348
  rgb.paste(rgba, mask=rgba.split()[3]) # 3 is the alpha channel
349
+ pdf_ = rgb.save("certificate.pdf", 'PDF', save_all = True, resolution=100.0)
350
+ print
351
  pdf = pdf_.filename
352
 
353
  return im, pdf
 
392
  last_name = gr.Textbox(placeholder="Doe", label="Your Last Name")
393
  #email = gr.Textbox(placeholder="jane.doe@gmail.com", label="Your Email (to receive your certificate)")
394
  check_progress_button = gr.Button(value="Check if I pass")
 
 
 
 
395
  check_progress_button.click(fn=certification, inputs=[hf_username, first_name, last_name], outputs=[output_text, output_pdf, output_img, output_dataframe])#[output1, output2])
396
+ with gr.Row(visible=False) as output_row:
397
+ output_text = gr.components.Textbox()
398
+ output_pdf = gr.File()
399
+ output_img = gr.components.Image(type="pil")
400
+ output_dataframe = gr.components.Dataframe(headers=["Pass?", "Unit", "Environment", "Baseline", "Your best result", "Your best model id"], datatype=["markdown", "markdown", "markdown", "number", "number", "markdown", "bool"]) #value= certification(hf_username, first_name, last_name),
401
+
402
  demo.launch(debug=True)