Spaces:
Runtime error

dnasafe commited on
Commit
3092881
·
verified ·
1 Parent(s): 025d308

fix input

Browse files
Files changed (1) hide show
  1. app.py +7 -12
app.py CHANGED
@@ -1,7 +1,6 @@
1
  import gradio as gr
2
 
3
-
4
- from phe import paillier
5
 
6
  # Generate Paillier keypair
7
  public_key, private_key = paillier.generate_paillier_keypair(n_length=1024)
@@ -16,9 +15,10 @@ print("===============================")
16
  # Input data as a text box
17
  data = gr.inputs.Textbox(label="Enter patient smoking status (smoker/non-smoker):", type="string")
18
 
19
- # Capture the user input
20
  user_input = data.value
21
 
 
22
  # Encode data as boolean values
23
  encoded_data = [1 if val == "smoker" else 0 for val in [user_input]]
24
 
@@ -34,14 +34,9 @@ print("Third party only sees encrypted data and cannot figure out the nature of
34
  print("=========================================")
35
  print(encrypted_data[0].ciphertext())
36
 
37
- # Perform homomorphic addition to count smokers
38
-
39
- encrypted_count = encrypted_data[0]
40
- for i in range(1, len(encrypted_data)):
41
- encrypted_count += encrypted_data[i]
42
 
43
- # Decrypt the result
44
- decrypted_count = private_key.decrypt(encrypted_count)
45
 
46
- # Output decrypted count
47
- gr.outputs.Text(label="Number of smokers:", value=decrypted_count)
 
1
  import gradio as gr
2
 
3
+ from phe import paillier
 
4
 
5
  # Generate Paillier keypair
6
  public_key, private_key = paillier.generate_paillier_keypair(n_length=1024)
 
15
  # Input data as a text box
16
  data = gr.inputs.Textbox(label="Enter patient smoking status (smoker/non-smoker):", type="string")
17
 
18
+ # capture the user input
19
  user_input = data.value
20
 
21
+
22
  # Encode data as boolean values
23
  encoded_data = [1 if val == "smoker" else 0 for val in [user_input]]
24
 
 
34
  print("=========================================")
35
  print(encrypted_data[0].ciphertext())
36
 
 
 
 
 
 
37
 
38
+ # Create a Gradio interface
39
+ iface = gr.Interface(fn=lambda x: x, inputs=data)
40
 
41
+ # Launch the interface
42
+ iface.launch(share=True)