SD_Defense / app.py
xinchen9's picture
Update app.py
c2be33a verified
import gradio as gr
import os
import requests
import json
from huggingface_hub import login
from css_html_js import custom_css
from about import (
CITATION_BUTTON_LABEL,
CITATION_BUTTON_TEXT,
EVALUATION_QUEUE_TEXT,
INTRODUCTION_TEXT,
LLM_BENCHMARKS_TEXT,
TITLE,
)
myip = "0.0.0.0"
myport=80
is_spaces = True if "SPACE_ID" in os.environ else False
is_shared_ui = False
with gr.Blocks() as demo:
gr.HTML(TITLE)
gr.Markdown(INTRODUCTION_TEXT, elem_classes="markdown-text")
with gr.Row() as advlearn:
drop = gr.Dropdown(["Object-Church", "Object-Parachute", "Object-Garbage_Truck","Object-Tench",
"Style-Van_Gogh","Concept-Nudity"],
label="Unlearning undesirable")
with gr.Column():
# gr.Markdown("Please upload your model id.")
drop_model = gr.Dropdown(["Erased Stable Diffusion(ESD)", "Forget-me-not(FMN)", "Ablating concepts(AC)","Unified Concept Editing(UCE)", "Safe Latent Diffusion(SLD)"],
label="Unlearned DMs")
with gr.Column():
# gr.Markdown("Please upload your model id.")
drop_text = gr.Dropdown(["Object-Church", "Object-Parachute", "Object-Garbage_Truck","Object-Tench",
"Style-Van_Gogh","Concept-Nudity", "None"],
label="AdvUnlearn Text Encoder")
with gr.Row() as attack:
text_input = gr.Textbox(label="Prompt")
with gr.Row():
with gr.Column(min_width=260):
img1 = gr.Image("images/cheetah.jpg",label="Image Generated without AdvUnlearn",width=260,show_share_button=False,show_download_button=False)
with gr.Column():
start_button = gr.Button("AdvUnlearn",size='lg')
with gr.Column(min_width=260):
img2 = gr.Image("images/cheetah.jpg",label="Image Generated with AdvUnlearn",width=260,show_share_button=False,show_download_button=False)
demo.launch()