bhky / opennsfw2 Goto Github PK
View Code? Open in Web Editor NEWKeras implementation of the Yahoo Open-NSFW model
License: MIT License
Keras implementation of the Yahoo Open-NSFW model
License: MIT License
My python version is 3.8, cuda version is 10.2.
would be nice to have a small website that allows users to demo the model instead of having to run it all, such as https://maybeshewill-cv.github.io/nsfw_classification/
I have my own porn dataset. How can I resume the training process with the the current model?
thanks
Best.
How to remove this from repo?
Hey!
Thanks for great work!
Your current work is using tensorflow and the highest supported CUDA driver version for TF gpu usage is 11.8
I am running CUDA 12.2, and cannot get to use ur code with gpu, as tf does not supports gpu for cuda above 11.8
Do u have any valuable resoruce to convert/ckpts this work in pytorch?
Please help resolve this error for python3.6
module 'opennsfw2' has no attribute 'predict_images'
It says no module named 'tree' when trying to install or run opennsfw2
Hello, and first of all, thank you for this fantastic project; I truly appreciate it.
I've encountered what may be a minor issue when using predict_images
in a for-loop, which results in an Out Of Memory (OOM) error on my 4GB RAM machine. After investigating the code, I found the following line:
opennsfw2/opennsfw2/_inference.py
Line 31 in 9654c1e
It appears that the model is created anew with every call to predict_images
, which could lead to memory leaks, as suggested by my testing. To address this, I attempted to move the model creation outside the function like this:
global_model = make_open_nsfw_model(weights_path=get_default_weights_path())
Then, I utilized the global model within the function, as shown below:
predictions = global_model.predict(images, batch_size=batch_size, verbose=0)
This change seems to have resolved the memory issue on my end.
At this time I might "piss you off" by asking to replace Pillow by OpenCV and Numpy? Most AI projects have this dependencies already so it makes sense to me - in our case I have the PIL dependency just for one line:
image = Image.fromarray(target_frame)
It's fine you close that issue instantly. Please consider it.
hello,
thanks for ur great work
can we get an example output of video processing ? like is it able to detect hentai or anime nudity too ?
Our low level implementation is causing an error once we update to the 0.11.0 release.
def predict_frame(target_frame : Frame) -> bool:
image = Image.fromarray(target_frame)
image = opennsfw2.preprocess_image(image, opennsfw2.Preprocessing.YAHOO)
views = numpy.expand_dims(image, axis = 0)
_, probability = get_predictor().predict(views)[0]
return probability > MAX_PROBABILITY
Source: https://github.com/facefusion/facefusion/blob/master/facefusion/predictor.py
Traceback (most recent call last):
File "/home/henry/PycharmProjects/facefusion/venv/lib/python3.10/site-packages/gradio/routes.py", line 523, in run_predict
output = await app.get_blocks().process_api(
File "/home/henry/PycharmProjects/facefusion/venv/lib/python3.10/site-packages/gradio/blocks.py", line 1437, in process_api
result = await self.call_function(
File "/home/henry/PycharmProjects/facefusion/venv/lib/python3.10/site-packages/gradio/blocks.py", line 1109, in call_function
prediction = await anyio.to_thread.run_sync(
File "/home/henry/PycharmProjects/facefusion/venv/lib/python3.10/site-packages/anyio/to_thread.py", line 33, in run_sync
return await get_asynclib().run_sync_in_worker_thread(
File "/home/henry/PycharmProjects/facefusion/venv/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 877, in run_sync_in_worker_thread
return await future
File "/home/henry/PycharmProjects/facefusion/venv/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 807, in run
result = context.run(func, *args)
File "/home/henry/PycharmProjects/facefusion/venv/lib/python3.10/site-packages/gradio/utils.py", line 865, in wrapper
response = f(*args, **kwargs)
File "/home/henry/PycharmProjects/facefusion/facefusion/uis/components/preview.py", line 95, in update_preview_image
preview_frame = process_preview_frame(target_frame)
File "/home/henry/PycharmProjects/facefusion/facefusion/uis/components/preview.py", line 118, in process_preview_frame
if predict_frame(temp_frame):
File "/home/henry/PycharmProjects/facefusion/facefusion/predictor.py", line 33, in predict_frame
_, probability = get_predictor().predict(views)[0]
File "/home/henry/PycharmProjects/facefusion/venv/lib/python3.10/site-packages/keras_core/src/utils/traceback_utils.py", line 123, in error_handler
raise e.with_traceback(filtered_tb) from None
File "/home/henry/PycharmProjects/facefusion/venv/lib/python3.10/site-packages/tensorflow/python/eager/execute.py", line 53, in quick_execute
tensors = pywrap_tfe.TFE_Py_Execute(ctx._handle, device_name, op_name,
tensorflow.python.framework.errors_impl.InternalError: Graph execution error:
Detected at node 'StatefulPartitionedCall' defined at (most recent call last):
File "/usr/lib/python3.10/threading.py", line 973, in _bootstrap
self._bootstrap_inner()
File "/usr/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
self.run()
File "/home/henry/PycharmProjects/facefusion/venv/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 807, in run
result = context.run(func, *args)
File "/home/henry/PycharmProjects/facefusion/venv/lib/python3.10/site-packages/gradio/utils.py", line 865, in wrapper
response = f(*args, **kwargs)
File "/home/henry/PycharmProjects/facefusion/facefusion/uis/components/preview.py", line 95, in update_preview_image
preview_frame = process_preview_frame(target_frame)
File "/home/henry/PycharmProjects/facefusion/facefusion/uis/components/preview.py", line 118, in process_preview_frame
if predict_frame(temp_frame):
File "/home/henry/PycharmProjects/facefusion/facefusion/predictor.py", line 33, in predict_frame
_, probability = get_predictor().predict(views)[0]
File "/home/henry/PycharmProjects/facefusion/venv/lib/python3.10/site-packages/keras_core/src/utils/traceback_utils.py", line 118, in error_handler
return fn(*args, **kwargs)
File "/home/henry/PycharmProjects/facefusion/venv/lib/python3.10/site-packages/keras_core/src/backend/tensorflow/trainer.py", line 504, in predict
batch_outputs = self.predict_function(data)
File "/home/henry/PycharmProjects/facefusion/venv/lib/python3.10/site-packages/keras_core/src/backend/tensorflow/trainer.py", line 210, in one_step_on_data_distributed
outputs = self.distribute_strategy.run(
Node: 'StatefulPartitionedCall'
libdevice not found at ./libdevice.10.bc
[[{{node StatefulPartitionedCall}}]] [Op:__inference_one_step_on_data_distributed_4826]
partially initialized module 'opennsfw2' has no attribute 'preprocess_image' (most likely due to a circular import)
这是什么原因啊
Hi, nice repo and good job!
Is there an officially recommend way how to run this inside Docker / Docker compose?
I'd appreciate if an official image is published as we have non python backend and this seems like the perfect use case.
Not a lot of configuration is needed IMO, just the port for the server and that's usually it.
Is there a chance you implement a frame range for video prediction like.
predict_video_frames(video_path, (100, 200))
Many people in my community gonna appreciate that.
Regards
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.