loubnabnl HF staff commited on
Commit
cdd3dc5
1 Parent(s): e8cf756
Files changed (1) hide show
  1. app.py +38 -0
app.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import gradio as gr
3
+ from huggingface_hub import create_discussion
4
+
5
+ token = os.environ["CLAIM"]
6
+ repo = "Team8/dataset"
7
+
8
+ description = """# <p style="text-align: center;"> Opt-Out from image datasets </p>
9
+ <span>This is a space to opt-out your images from some datasets. After you check that your image is in the dataset,
10
+ fill an explanation for why you want it to be removed. If you want to be notified when the image is removed,
11
+ fill your email. Additionally if you want to encrypt your issue opened on the dataset, check the Encrypt box.</span>"""
12
+
13
+ def open_issue(explanation, email, encrypt):
14
+ create_discussion(
15
+ repo_id=repo,
16
+ repo_type="dataset",
17
+ title="[OPT-OUT REQUEST] Remove image from the dataset",
18
+ description=explanation + "\n User email: " + email + "\n Encrypt: " + str(encrypt),
19
+ token = token,
20
+ )
21
+ # to do add issue id to the link
22
+ link = f"https://huggingface.co/datasets/{repo}/discussions"
23
+ return f"Issue opened at {link}"
24
+
25
+ demo = gr.Blocks()
26
+ with demo:
27
+ with gr.Row():
28
+ gr.Markdown(value=description)
29
+ with gr.Row():
30
+ with gr.Column():
31
+ explanation = gr.Textbox(lines=5, label="Please explain in a few lines why you want this image to be removed from the dataset.")
32
+ email = gr.Textbox(lines=1, label="Fill your email if you want to be notified when the image is removed.")
33
+ encrypt = gr.Checkbox(label="Encrypt my message")
34
+ run = gr.Button("Open an issue on the dataset")
35
+ output = gr.Textbox(lines=1, label="Opened issue link")
36
+ event = run.click(open_issue, [explanation, email, encrypt],output, api_name="open_issue")
37
+
38
+ demo.launch()