Skip to content

Commit

Permalink
Adding Hugging Face token input
Browse files Browse the repository at this point in the history
  • Loading branch information
MMqd committed Jul 23, 2023
1 parent ce12b17 commit a04a829
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
7 changes: 6 additions & 1 deletion scripts/deepfloydif.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
from modules.shared import opts, state
from modules.sd_models import CheckpointInfo
from modules.paths_internal import script_path
from huggingface_hub import login


import sys
sys.path.append('extensions/kandinsky-for-automatic1111/scripts')
Expand All @@ -29,7 +31,10 @@ def __init__(self):
self.cache_dir = os.path.join(os.path.join(script_path, 'models'), 'IF')

def load_encoder(self):
self.pipe = self.load_pipeline("pipe", IFPipeline, "DeepFloyd/IF-I-XL-v1.0")
try:
self.pipe = self.load_pipeline("pipe", IFPipeline, "DeepFloyd/IF-I-XL-v1.0")
except FileNotFoundError as fe:
errors.print_error_explanation(f'File {fe.filename} not found. Did you forget the Hugging Face token?')

def run_encoder(self, prior_settings_dict):
if prior_settings_dict.get("negative_prompt", None) is None:
Expand Down
15 changes: 13 additions & 2 deletions scripts/deepfloydif_script.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
from modules import errors
try:
from huggingface_hub import login
except ImportError as e:
errors.print_error_explanation('RESTART AUTOMATIC1111 COMPLETELY TO FINISH INSTALLING PACKAGES FOR kandinsky-for-automatic1111')


import sys
import torch
import gradio as gr
Expand Down Expand Up @@ -62,11 +69,13 @@ def ui(self, is_img2img):
reload_sd_model
unload_k_model

inputs = []
token_textbox = gr.inputs.Textbox(label="Hugging Face Token", type="password")

inputs = [token_textbox]

return inputs

def run(self, p) -> Processed:
def run(self, p, token) -> Processed:
p.sampler_name = "DDPM"
p.init_image = getattr(p, 'init_images', None)
p.extra_generation_params["Script"] = self.title()
Expand All @@ -75,5 +84,7 @@ def run(self, p) -> Processed:

if shared.if_model is None:
shared.if_model = IFModel()
if token != "":
login(token=token)

return shared.if_model.process_images(p)

0 comments on commit a04a829

Please sign in to comment.