mirror of
https://github.com/easydiffusion/easydiffusion.git
synced 2025-04-22 10:28:34 +02:00
Merge pull request #1539 from easydiffusion/beta
Server-side setting to block_nsfw
This commit is contained in:
commit
fc9941abaa
@ -17,6 +17,7 @@
|
|||||||
- **Major rewrite of the code** - We've switched to using diffusers under-the-hood, which allows us to release new features faster, and focus on making the UI and installer even easier to use.
|
- **Major rewrite of the code** - We've switched to using diffusers under-the-hood, which allows us to release new features faster, and focus on making the UI and installer even easier to use.
|
||||||
|
|
||||||
### Detailed changelog
|
### Detailed changelog
|
||||||
|
* 3.0.2 - 30 Aug 2023 - Allow blocking NSFW images using a server-side config. This prevents the browser from generating NSFW images or changing the config. Open `config.yaml` in a text editor (e.g. Notepad), and add `block_nsfw: true` at the end, and save the file.
|
||||||
* 3.0.2 - 29 Aug 2023 - Fixed incorrect matching of embeddings from prompts.
|
* 3.0.2 - 29 Aug 2023 - Fixed incorrect matching of embeddings from prompts.
|
||||||
* 3.0.2 - 24 Aug 2023 - Fix broken seamless tiling.
|
* 3.0.2 - 24 Aug 2023 - Fix broken seamless tiling.
|
||||||
* 3.0.2 - 23 Aug 2023 - Fix styling on mobile devices.
|
* 3.0.2 - 23 Aug 2023 - Fix styling on mobile devices.
|
||||||
|
@ -36,6 +36,7 @@ NOCACHE_HEADERS = {
|
|||||||
"Pragma": "no-cache",
|
"Pragma": "no-cache",
|
||||||
"Expires": "0",
|
"Expires": "0",
|
||||||
}
|
}
|
||||||
|
PROTECTED_CONFIG_KEYS = ("block_nsfw",) # can't change these via the HTTP API
|
||||||
|
|
||||||
|
|
||||||
class NoCacheStaticFiles(StaticFiles):
|
class NoCacheStaticFiles(StaticFiles):
|
||||||
@ -175,7 +176,7 @@ def set_app_config_internal(req: SetAppConfigRequest):
|
|||||||
config["test_diffusers"] = req.test_diffusers
|
config["test_diffusers"] = req.test_diffusers
|
||||||
|
|
||||||
for property, property_value in req.dict().items():
|
for property, property_value in req.dict().items():
|
||||||
if property_value is not None and property not in req.__fields__:
|
if property_value is not None and property not in req.__fields__ and property not in PROTECTED_CONFIG_KEYS:
|
||||||
config[property] = property_value
|
config[property] = property_value
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -456,6 +457,7 @@ def modify_package_internal(package_name: str, req: dict):
|
|||||||
log.error(traceback.format_exc())
|
log.error(traceback.format_exc())
|
||||||
return HTTPException(status_code=500, detail=str(e))
|
return HTTPException(status_code=500, detail=str(e))
|
||||||
|
|
||||||
|
|
||||||
def get_sha256_internal(obj_path):
|
def get_sha256_internal(obj_path):
|
||||||
import hashlib
|
import hashlib
|
||||||
from easydiffusion.utils import sha256sum
|
from easydiffusion.utils import sha256sum
|
||||||
@ -477,4 +479,3 @@ def get_sha256_internal(obj_path):
|
|||||||
log.error(str(e))
|
log.error(str(e))
|
||||||
log.error(traceback.format_exc())
|
log.error(traceback.format_exc())
|
||||||
return HTTPException(status_code=500, detail=str(e))
|
return HTTPException(status_code=500, detail=str(e))
|
||||||
|
|
||||||
|
@ -42,9 +42,16 @@ class RenderTask(Task):
|
|||||||
def run(self):
|
def run(self):
|
||||||
"Runs the image generation task on the assigned thread"
|
"Runs the image generation task on the assigned thread"
|
||||||
|
|
||||||
from easydiffusion import task_manager
|
from easydiffusion import task_manager, app
|
||||||
|
|
||||||
context = runtime.context
|
context = runtime.context
|
||||||
|
config = app.getConfig()
|
||||||
|
|
||||||
|
if config.get("block_nsfw", False): # override if set on the server
|
||||||
|
self.task_data.block_nsfw = True
|
||||||
|
if "nsfw_checker" not in self.task_data.filters:
|
||||||
|
self.task_data.filters.append("nsfw_checker")
|
||||||
|
self.models_data.model_paths["nsfw_checker"] = "nsfw_checker"
|
||||||
|
|
||||||
def step_callback():
|
def step_callback():
|
||||||
task_manager.keep_task_alive(self)
|
task_manager.keep_task_alive(self)
|
||||||
|
Loading…
Reference in New Issue
Block a user