tongyx361 commited on
Commit
76c65ef
·
1 Parent(s): fa9d1b1

Update app.py to insert ImageReward

Browse files

1. install dependency for ImageReward
2. add the custom script `image_reward.py` into SD Web UI

Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -7,6 +7,9 @@ if("A10G" in gpu_info):
7
  elif("T4" in gpu_info):
8
  os.system(f"pip install -q https://github.com/camenduru/stable-diffusion-webui-colab/releases/download/0.0.15/xformers-0.0.15.dev0+1515f77.d20221130-cp38-cp38-linux_x86_64.whl")
9
 
 
 
 
10
  os.system(f"git clone -b v1.5 https://github.com/camenduru/stable-diffusion-webui /home/user/app/stable-diffusion-webui")
11
  os.chdir("/home/user/app/stable-diffusion-webui")
12
 
@@ -24,13 +27,15 @@ os.system(f"sed -i -e 's/ outputs=\[/queue=False, &/g' /home/user/app/stable-dif
24
  os.system(f"sed -i -e 's/ queue=False, / /g' /home/user/app/stable-diffusion-webui/modules/ui.py")
25
 
26
  # ----------------------------Please duplicate this space and delete this block if you don't want to see the extra header----------------------------
27
- os.system(f"wget -q https://github.com/camenduru/webui/raw/main/header_patch.py -O /home/user/app/header_patch.py")
28
  os.system(f"sed -i -e '/demo:/r /home/user/app/header_patch.py' /home/user/app/stable-diffusion-webui/modules/ui.py")
29
  # ---------------------------------------------------------------------------------------------------------------------------------------------------
30
 
31
  if "IS_SHARED_UI" in os.environ:
32
  os.system(f"rm -rfv /home/user/app/stable-diffusion-webui/scripts/")
33
-
 
 
34
  os.system(f"wget -q https://github.com/camenduru/webui/raw/main/shared-config.json -O /home/user/app/shared-config.json")
35
  os.system(f"wget -q https://github.com/camenduru/webui/raw/main/shared-ui-config.json -O /home/user/app/shared-ui-config.json")
36
 
@@ -43,6 +48,8 @@ if "IS_SHARED_UI" in os.environ:
43
  else:
44
  # Please duplicate this space and delete # character in front of the custom script you want to use or add here more custom scripts with same structure os.system(f"wget -q https://CUSTOM_SCRIPT_URL -O /home/user/app/stable-diffusion-webui/scripts/CUSTOM_SCRIPT_NAME.py")
45
  os.system(f"wget -q https://gist.github.com/camenduru/9ec5f8141db9902e375967e93250860f/raw/d0bcf01786f20107c329c03f8968584ee67be12a/run_n_times.py -O /home/user/app/stable-diffusion-webui/scripts/run_n_times.py")
 
 
46
 
47
  # Please duplicate this space and delete # character in front of the extension you want to use or add here more extensions with same structure os.system(f"git clone https://EXTENSION_GIT_URL /home/user/app/stable-diffusion-webui/extensions/EXTENSION_NAME")
48
  #os.system(f"git clone https://github.com/camenduru/stable-diffusion-webui-artists-to-study /home/user/app/stable-diffusion-webui/extensions/stable-diffusion-webui-artists-to-study")
 
7
  elif("T4" in gpu_info):
8
  os.system(f"pip install -q https://github.com/camenduru/stable-diffusion-webui-colab/releases/download/0.0.15/xformers-0.0.15.dev0+1515f77.d20221130-cp38-cp38-linux_x86_64.whl")
9
 
10
+ # install dependency for ImageReward
11
+ os.system(f"pip install -q image-reward")
12
+
13
  os.system(f"git clone -b v1.5 https://github.com/camenduru/stable-diffusion-webui /home/user/app/stable-diffusion-webui")
14
  os.chdir("/home/user/app/stable-diffusion-webui")
15
 
 
27
  os.system(f"sed -i -e 's/ queue=False, / /g' /home/user/app/stable-diffusion-webui/modules/ui.py")
28
 
29
  # ----------------------------Please duplicate this space and delete this block if you don't want to see the extra header----------------------------
30
+ os.system(f"wget -q https://raw.githubusercontent.com/tongyx361/ImageReward-in-SD-Web-UI/main/header_patch.py -O /home/user/app/header_patch.py")
31
  os.system(f"sed -i -e '/demo:/r /home/user/app/header_patch.py' /home/user/app/stable-diffusion-webui/modules/ui.py")
32
  # ---------------------------------------------------------------------------------------------------------------------------------------------------
33
 
34
  if "IS_SHARED_UI" in os.environ:
35
  os.system(f"rm -rfv /home/user/app/stable-diffusion-webui/scripts/")
36
+ # add the custom script `image_reward.py` into SD Web UI
37
+ os.system(f"wget -q https://raw.githubusercontent.com/THUDM/ImageReward/main/demo/sdwebui/image_reward.py -O /home/user/app/stable-diffusion-webui/scripts/image_reward.py")
38
+
39
  os.system(f"wget -q https://github.com/camenduru/webui/raw/main/shared-config.json -O /home/user/app/shared-config.json")
40
  os.system(f"wget -q https://github.com/camenduru/webui/raw/main/shared-ui-config.json -O /home/user/app/shared-ui-config.json")
41
 
 
48
  else:
49
  # Please duplicate this space and delete # character in front of the custom script you want to use or add here more custom scripts with same structure os.system(f"wget -q https://CUSTOM_SCRIPT_URL -O /home/user/app/stable-diffusion-webui/scripts/CUSTOM_SCRIPT_NAME.py")
50
  os.system(f"wget -q https://gist.github.com/camenduru/9ec5f8141db9902e375967e93250860f/raw/d0bcf01786f20107c329c03f8968584ee67be12a/run_n_times.py -O /home/user/app/stable-diffusion-webui/scripts/run_n_times.py")
51
+ # add the custom script `image_reward.py` into SD Web UI
52
+ os.system(f"wget -q https://raw.githubusercontent.com/THUDM/ImageReward/main/demo/sdwebui/image_reward.py -O /home/user/app/stable-diffusion-webui/scripts/image_reward.py")
53
 
54
  # Please duplicate this space and delete # character in front of the extension you want to use or add here more extensions with same structure os.system(f"git clone https://EXTENSION_GIT_URL /home/user/app/stable-diffusion-webui/extensions/EXTENSION_NAME")
55
  #os.system(f"git clone https://github.com/camenduru/stable-diffusion-webui-artists-to-study /home/user/app/stable-diffusion-webui/extensions/stable-diffusion-webui-artists-to-study")