<jupyter_start><jupyter_text>Demo of Texutre Modulation - Import- Demo for Sec.4.4- Demo for Sec.5.2  Import<jupyter_code>#!/usr/bin/env python
# -*- coding: utf-8 -*-
import time
import math
import numpy as np
import torch
import torch.nn as nn
import torch.nn.parallel
import torch.backends.cudnn as cudnn
import torch.optim as optim
import torch.utils.data
from torch.utils.data import DataLoader
from torchvision.models.utils import load_state_dict_from_url
from torch.utils.data.dataset import Subset,ConcatDataset
import torchvision.transforms as transforms
import torchvision.utils as vutils
import torchvision
import torch.nn.functional as F
from torch.autograd import Variable
import utils
import os
import sys
import pickle
from PIL import Image
from matplotlib import pyplot as plt
import glob
from omegaconf import OmegaConf
import omegaconf
from models import *
from ipywidgets import interact, FloatSlider,fixed,interact_manual
###################
from texture_modulation_demo import TM_Demo
###############<jupyter_output><empty_output><jupyter_text>Demo for Section4.4<jupyter_code># This is additional config.You can change config here.
sys.argv = ['Do_not_remove.py','experiment.sigma=70','experiment.best_model=Color70_GTCNN_D1','experiment.device_ids=[2]'] 
rol = 0.5 # range_of_lambda

######################################
# Config load and merge
conf = OmegaConf.load('confs/GTCNN.yaml')
OmegaConf.set_struct(conf, True)
conf.merge_with_cli()
#####################################

image_path  = './163085.png' # image path
Demo = TM_Demo(image_path,conf) # Demo code
print('TOP Image : Modulated Image')
print('Bottom Image : Not Modulated Image')
interact(Demo.ex_test,
         e_0=fixed(0),
         e_1=fixed(0),
         e_2=FloatSlider(min=-rol, max=rol, step=0.0001, value=0, continuous_update=False),
         e_3=fixed(0),
         e_4=fixed(0),)<jupyter_output>------------------------
TOP Image : Modulated Image
Bottom Image : Not Modulated Image<jupyter_text>Gray-scale Demo for SupMat<jupyter_code># This is additional config.You can change config here.
sys.argv = ['Do_not_remove.py','experiment.sigma=50','experiment.color=1','experiment.best_model=Gray50_GTCNN_D1','experiment.device_ids=[2]'] 
rol = 0.5 # range_of_lambda

######################################
# Config load and merge
conf = OmegaConf.load('confs/GTCNN.yaml')
OmegaConf.set_struct(conf, True)
conf.merge_with_cli()
#####################################

image_path  = './163085.png' # image path
Demo = TM_Demo(image_path,conf) # Demo code
print('TOP Image : Modulated Image')
print('Bottom Image : Not Modulated Image')
interact(Demo.ex_test,
         e_0=fixed(0),
         e_1=fixed(0),
         e_2=FloatSlider(min=-rol, max=rol, step=0.0001, value=0, continuous_update=False),
         e_3=fixed(0),
         e_4=fixed(0),)<jupyter_output>------------------------
TOP Image : Modulated Image
Bottom Image : Not Modulated Image<jupyter_text>Demo for Section5.2 (ablation study)You can modulate any output of skipconection<jupyter_code># This is additional config.You can change config here.
sys.argv = ['Do_not_remove.py','experiment.sigma=70','experiment.best_model=Color70_GTCNN_D1','experiment.device_ids=[2]'] 
rol = 0.5 # range_of_lambda

######################################
# Config load and merge
conf = OmegaConf.load('confs/GTCNN.yaml')
OmegaConf.set_struct(conf, True)
conf.merge_with_cli()
#####################################


image_path  = './163085.png' # image path
Demo = TM_Demo(image_path,conf) # Demo code
print('TOP Image : Modulated Image')
print('Bottom Image : Not Modulated Image')
interact(Demo.ex_test,
         e_0=FloatSlider(min=-rol, max=rol, step=0.0001, value=0, continuous_update=False),
         e_1=FloatSlider(min=-rol, max=rol, step=0.0001, value=0, continuous_update=False),
         e_2=FloatSlider(min=-rol, max=rol, step=0.0001, value=0, continuous_update=False),
         e_3=FloatSlider(min=-rol, max=rol, step=0.0001, value=0, continuous_update=False),
         e_4=FloatSlider(min=-rol, max=rol, step=0.0001, value=0, continuous_update=False))<jupyter_output>------------------------
TOP Image : Modulated Image
Bottom Image : Not Modulated Image
{'fraction_non_alphanumeric': 0.18356684872951792, 'fraction_numerical': 0.027784374257895986, 'mean_word_length': 5.095513748191028, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '140487', 'license': 'Apache-2.0', 'n_tokens_mistral': 1432, 'n_tokens_neox': 1349, 'n_words': 315, 'path': 'Demo_Texture_Modification.ipynb', 'repo_name': 'mdipcit/GTCNN', 'size': '4211'}