Update app.py
Browse files
app.py
CHANGED
|
@@ -14,7 +14,7 @@ DEFAULT_IMAGE = "original_image.jpg"
|
|
| 14 |
with open(SEMANTIC_DIPOLES_FILE, "r") as f:
|
| 15 |
semantic_dipoles = json.load(f)
|
| 16 |
# Transform semantic_dipoles into "A -> B" format
|
| 17 |
-
formatted_dipoles = [f"{pair[
|
| 18 |
|
| 19 |
# Helper to list all latent code folders
|
| 20 |
latent_code_folders = sorted(
|
|
@@ -55,12 +55,15 @@ def display_image(latent_code, formatted_dipole, frame_idx):
|
|
| 55 |
|
| 56 |
# Function to display GAN latent space interactive plot
|
| 57 |
def display_interactive_plot(latent_code):
|
| 58 |
-
file_path = f"files/{LATENT_CODES_DIR}/{latent_code}/interactive_latent_space_{latent_code}.html"
|
|
|
|
| 59 |
iframe_html = f'<iframe src="{file_path}" width="800" height="600" frameborder="0"></iframe>'
|
| 60 |
return iframe_html
|
| 61 |
|
|
|
|
|
|
|
| 62 |
# Gradio Interface
|
| 63 |
-
def build_interface():
|
| 64 |
with gr.Blocks() as demo:
|
| 65 |
gr.Markdown("# ContraCLIP-based Image Editing and Visualization Demo")
|
| 66 |
|
|
|
|
| 14 |
with open(SEMANTIC_DIPOLES_FILE, "r") as f:
|
| 15 |
semantic_dipoles = json.load(f)
|
| 16 |
# Transform semantic_dipoles into "A -> B" format
|
| 17 |
+
formatted_dipoles = [f"{pair[1]]} -> {pair[0]}" for pair in semantic_dipoles]
|
| 18 |
|
| 19 |
# Helper to list all latent code folders
|
| 20 |
latent_code_folders = sorted(
|
|
|
|
| 55 |
|
| 56 |
# Function to display GAN latent space interactive plot
|
| 57 |
def display_interactive_plot(latent_code):
|
| 58 |
+
# file_path = f"files/{LATENT_CODES_DIR}/{latent_code}/interactive_latent_space_{latent_code}.html"
|
| 59 |
+
file_path = f"/file/ContraCLIP/experiments/wip/ContraCLIP_stylegan2_ffhq1024-W-K21-D128-lss_beta_0.1-eps0.1_0.2-nonlinear_css_beta_0.5-contrastive_0.5-5000-expressions/results/stylegan2_ffhq1024-4/32_0.2_6.4/{latent_code}/interactive_latent_space_{latent_code}.html"
|
| 60 |
iframe_html = f'<iframe src="{file_path}" width="800" height="600" frameborder="0"></iframe>'
|
| 61 |
return iframe_html
|
| 62 |
|
| 63 |
+
|
| 64 |
+
|
| 65 |
# Gradio Interface
|
| 66 |
+
def build_interface():
|
| 67 |
with gr.Blocks() as demo:
|
| 68 |
gr.Markdown("# ContraCLIP-based Image Editing and Visualization Demo")
|
| 69 |
|