Comments (1)
The extension detects if a model is not in the CivitAI servers by checking the model ID of the associated .json file.
For example:
{
"sha256": "Model_hash",
"modelId": "Model not found"
}
If the modelId is set to "Model not found" then it will skip the model (by default it also logs the "not found on CivitAI servers" message which is toggleable in the settings) and it then does not process the file in an API request.
If a model has not been processed yet, then as long as the sha256 generation is turned on, it then generates a sha256 hash and sends a request to the CivitAI API, then when it receives a 404 return, indicating the model does not exist, then the CivitAI API returns "error": "Model not found"
, the code then grabs the return from the error and sets it as the model ID, which then in the future will be read and no longer processed.
The only change I can think of is to manually set a model ID to "Model not found" instead of reading the returned error, but the current code already stops processing files if they were previously not found, like I wrote in the previous bug report.
Additionally you can check the associated .json files of the models to check their Model IDs in case they are getting individual API requests for each file, I suspect this to be the issue, as the current code should correctly handle skipping models.
here is the relevant code in case you're interested along with some comments explaining the steps:
first the get_models
function is ran for every file.
def get_models(file_path, gen_hash=None):
# First we try to read the json file and get an exesting model ID, if present
if not modelId or not modelVersionId or not sha256: # If no model ID, version ID, or sha256 is found, try to generate a sha256 hash
if not sha256 and gen_hash:
sha256 = gen_sha256(file_path)
if sha256:
by_hash = f"https://civitai.com/api/v1/model-versions/by-hash/{sha256}"
else:
return modelId if modelId else None # If no sha256 hash could be created, try to use the current model ID, if available, else none.
proxies, ssl = _api.get_proxies()
try:
if not modelId or not modelVersionId:
response = requests.get(by_hash, timeout=(60,30), proxies=proxies, verify=ssl) # Send an API request with the sha256 hash
if response.status_code == 200:
api_response = response.json()
if 'error' in api_response:
print(f"\"{file_path}\": {api_response['error']}")
return None
else:
modelId = api_response.get("modelId", "")
modelVersionId = api_response.get("id", "")
elif response.status_code == 503:
return "offline"
elif response.status_code == 404: # If no model is returned, aka a 404 error, then set the model to the returned error, being "Model not found"
api_response = response.json()
modelId = api_response.get("error", "")
# Later on the model ID and other found info are saved to the associated .json file.
model_id = get_models(file_path, gen_hash) # Get the model ID from the get_models function
if model_id == "offline":
print("The CivitAI servers did not respond, unable to retrieve Model ID")
elif model_id == "Model not found": # Check if the models ID = "Model not found" if so, skip the model and do not add it to the list of valid models.
if not_found_print:
print(f"model: \"{file_name}\" not found on CivitAI servers.")
As far as I can tell there is currently not an issue with the way that the code handles the issue you're experiencing, so I'll close this bug report as it's not something that I can fix, you're free to ask other questions about why this might be happening.
from sd-civitai-browser-plus.
Related Issues (20)
- [Bug or not?]: can't save image, when i use proxy(socks5://myproxyip:myproxyport). HOT 2
- [Bug]: activation text stopped working due to two json files HOT 2
- [Bug]: HOT 5
- [Bug]: extension only works the first time its intalled. HOT 2
- 471749[Bug]: Python module 'fake_useragent' has not been imported correctly, please try to restart or install it manually. HOT 2
- [Bug]: Some models not showing up in the search results HOT 2
- [Bug]: Drives other than C: break HOT 3
- [Bug]: Stopped working as intended HOT 3
- [Bug]: Search does not work after fresh install HOT 2
- [Bug]: Continually attempts to reinstall requirements 3X HOT 2
- [Bug]: Setting Custom save images location breaks Use local HTML file for model info when Use local images in the HTML is enabled.
- [Bug]: Extension silently overwrites models with the same filename. HOT 3
- [Bug]: Several models not updated preview HOT 5
- [Bug]: AttributeError: 'Namespace' object has no attribute 'controlnet_dir' HOT 8
- [Bug]: Downloading all html despite unchecked HOT 3
- [Bug]: ModernUi of SDnext (missing Quicksettings)
- [Bug]: Updating tags still sends API and Saves for all despite unchecked HOT 1
- [Bug]: HOT 1
- [Bug]: Search result nth +1 tile is not displayed HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sd-civitai-browser-plus.