OSError: None is not a local folder and is not a valid model identifier listed on 'https://huggingface.co/models'

Dmitr: <p>Hi! i have one more problem with AI moels. Now python complains about that i don’t have access to huggingface repository. I don’t know why it happens, i run models locally.</p>
<p><strong>I have next error:</strong></p>
<pre><code class="lang-auto">OSError: None is not a local folder and is not a valid model identifier listed on 'https://huggingface.co/models'
If this is a private repository, make sure to pass a token having permission to this repo with `token` or log in with `huggingface-cli login`.
</code></pre>
<p>Code</p>
<pre><code class="lang-auto">import torch
from controlnet_aux import CannyDetector
from diffusers import StableDiffusionControlNetPipeline, ControlNetModel
from diffusers.utils import load_image, make_image_grid
import os

MMIX_MODEL_PATH = os.getenv('MMIX_MODEL_PATH')
IP_ADAPTER_PATH = os.getenv('IP_ADAPTER')
CANNY_MODEL_PATH=os.getenv('CANNY_MODEL')

img1 = 'C:\\image-4.png'
img2 = 'C:\\image-3.png'


controlnet = ControlNetModel.from_pretrained(
    CANNY_MODEL_PATH,
    torch_dtype=torch.float16
    #varient="fp16"
)


pipe = StableDiffusionControlNetPipeline.from_pretrained(
    MMIX_MODEL_PATH,
    controlnet=controlnet,
    torch_dtype=torch.float16)


pipe.load_ip_adapter(
                     IP_ADAPTER_PATH,
                     subfolder="models",
weight_name="ip-adapter_sd15.bin"
)


ip_adap_img = load_image(img2)
img = load_image(img1).resize((768, 768))

canny = CannyDetector()
canny_img = canny(img, detect_resolution=512, image_resolution=768)


prompt = """(photorealistic:1.2), raw, masterpiece, high quality, 8k, girl wearing hoodie, headphones, hands in pocket"""
negative_prompt = "low quality, ugly, mutated"

pipe.set_ip_adapter_scale(0.5)

images = pipe(prompt = prompt,
              negative_prompt = negative_prompt,
              height = 768,
              width = 768,
              ip_adapter_image = ip_adap_img,
              image = canny_img,
              guidance_scale = 6,
              controlnet_conditioning_scale = 0.7,
              num_inference_steps = 20
              ).images[0]</code></pre>

ptrblck: <p>Check your env variables as I assume these are not set:</p>
<pre data-code-wrap="python"><code class="lang-python">import os

MMIX_MODEL_PATH = os.getenv('MMIX_MODEL_PATH')
print(MMIX_MODEL_PATH)
# None
</code></pre>

Dmitr: <p>Thanks. I checked my code and realized that I forgot to add <code> load_dotenv()</code><br>
I would also be grateful if you could look at my other problem related to inpainting.</p><aside class="quote quote-modified" data-post="1" data-topic="216995">
  <div class="title">
    <div class="quote-controls"></div>
    <img alt="" width="24" height="24" src="https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/d/13edae/48.png" class="avatar">
    <a href="https://discuss.pytorch.org/t/problem-with-inpainting-stable-diffusion-and-python/216995">Problem with inpainting Stable Diffusion and python</a> 
  </div>
  <blockquote>
    Inpainting Stable Diffusion 
Hi. I’m trying to change the background of a photo from a wall to a forest, but Stable Diffusion distorts the girl’s face very much. Can you look at my python code and tell me what I did wrong? I tried different models, but the result is still not very good. 
import os
from dotenv import load_dotenv
import torch
import numpy as np
from diffusers import AutoPipelineForInpainting, EulerDiscreteScheduler, ControlNetModel, StableDiffusionControlNetInpaintPipeline
from PI…
  </blockquote>
</aside>