Spaces:
Runtime error

dnasafe commited on
Commit
aa98dc4
·
verified ·
1 Parent(s): eceb35f

add help text and desc

Browse files
Files changed (1) hide show
  1. app.py +22 -6
app.py CHANGED
@@ -13,7 +13,7 @@ def secure_encoding(input_data):
13
  print("Input Data:", data)
14
 
15
  # Encode data
16
- encoded_data = [1 if val.split(':')[1] == "1" else 0 for val in data]
17
  print("Encoded Data:", encoded_data)
18
 
19
  # Encrypt and send to cloud
@@ -41,15 +41,31 @@ def secure_encoding(input_data):
41
  print("Send result to the data owner")
42
  print("Decrypted Count:", decrypted_count)
43
 
44
- return f"Encrypted Ciphertext: {encrypted_data[0].ciphertext()}", f"Encrypted Count: {encrypted_count}", f"Decrypted Count: {decrypted_count}"
 
 
 
 
 
45
 
46
  # Gradio Interface
47
  iface = gr.Interface(
48
  fn=secure_encoding,
49
- inputs="text",
50
- outputs=["text", "text", "text"],
51
- live=True
 
 
 
 
 
 
 
 
 
 
 
52
  )
53
 
54
  # Launch the Gradio app
55
- iface.launch()
 
13
  print("Input Data:", data)
14
 
15
  # Encode data
16
+ encoded_data = [1 if "smoker" in val.lower() else 0 for val in data]
17
  print("Encoded Data:", encoded_data)
18
 
19
  # Encrypt and send to cloud
 
41
  print("Send result to the data owner")
42
  print("Decrypted Count:", decrypted_count)
43
 
44
+ return (
45
+ f"Encrypted Ciphertext of the First Element: {encrypted_data[0].ciphertext()}",
46
+ f"Encrypted Count: {encrypted_count}",
47
+ f"Decrypted Count: {decrypted_count}",
48
+ "Data processing is complete. The encrypted data and count have been generated."
49
+ )
50
 
51
  # Gradio Interface
52
  iface = gr.Interface(
53
  fn=secure_encoding,
54
+ inputs=gr.Textbox("text", placeholder="Enter data (e.g., smokers, non-smokers)"),
55
+ outputs=[
56
+ gr.Textbox("text", label="Encrypted Ciphertext"),
57
+ gr.Textbox("text", label="Encrypted Count"),
58
+ gr.Textbox("text", label="Decrypted Count"),
59
+ gr.Textbox("text", label="Process Description")
60
+ ],
61
+ live=True,
62
+ title="Paillier Encryption Demonstration",
63
+ description="This app demonstrates Paillier encryption. Enter data (e.g., smokers, non-smokers) in the textbox, and the app will perform encryption and homomorphic addition.",
64
+ examples=[
65
+ ["smokers", "non-smokers", "smokers", "smokers", "non-smokers", "smokers", "non-smokers"],
66
+ ["smokers", "non-smokers", "non-smokers", "smokers", "smokers", "non-smokers", "smokers"]
67
+ ]
68
  )
69
 
70
  # Launch the Gradio app
71
+ iface.launch()