{"id":17596118,"url":"https://github.com/fyko/nsfw","last_synced_at":"2025-04-14T21:45:52.869Z","repository":{"id":205682311,"uuid":"714834009","full_name":"Fyko/nsfw","owner":"Fyko","description":"A Rust library for detecting NSFW images using a neural network","archived":false,"fork":false,"pushed_at":"2025-04-05T18:00:00.000Z","size":139,"stargazers_count":16,"open_issues_count":3,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-05T18:35:00.023Z","etag":null,"topics":["ml","nsfw","onnx","tract"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Fyko.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-11-05T23:41:48.000Z","updated_at":"2025-03-29T11:56:26.000Z","dependencies_parsed_at":null,"dependency_job_id":"3a53fa0e-5929-4b18-aa7a-b20230a23e9f","html_url":"https://github.com/Fyko/nsfw","commit_stats":{"total_commits":48,"total_committers":2,"mean_commits":24.0,"dds":0.25,"last_synced_commit":"1d85f50caac9c4d3fba92764e9b2b096840b181e"},"previous_names":["fyko/nsfw"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fyko%2Fnsfw","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fyko%2Fnsfw/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fyko%2Fnsfw/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fyko%2Fnsfw/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Fyko","download_url":"https://codeload.github.com/Fyko/nsfw/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248966928,"owners_count":21190870,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ml","nsfw","onnx","tract"],"created_at":"2024-10-22T08:07:56.392Z","updated_at":"2025-04-14T21:45:52.847Z","avatar_url":"https://github.com/Fyko.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NSFW?\n\n[![crates.io]](https://crates.io/crates/nsfw)\n[![Documentation]](https://docs.rs/nsfw)\n[![Build Status]](https://github.com/Fyko/nsfw/actions/workflows/test.yml)\n[![Discord]](https://discord.gg/RU3FhmX3Ja)\n\n`nsfw` is a library for determining the not-safe-for-work-ness of images.\nIt is based off of [GantMan's model].\n\n## Prerequisites\n\nBecause Cargo has a size limit of 10mb, the pre-trained model cannot be included in the crate.\nYou will need to download it from [the release page] or download the model yourself and convert it into [ONNX]\n\n### Downloading from [the release page] (easy)\n\n```sh\n$ gh release download -R Fyko/nsfw --pattern \"model.onnx\"\n# or naviate to the release page and download it manually\n```\n\n### Convering from [GantMan's model]\n\nSee our [GitHub Workflow]\n\n## Example: Static Images\n\n```toml\n[dependencies]\nimage = { version = \"0.24.7\", default-features = false, features = [\"jpeg\"] }\nnsfw = { version = \"0.1.0\", default-features = false, features = [\"jpeg\"] }\n```\n\n```rust,no_test\nuse nsfw::{create_model, examine};\n\nfn main() -\u003e Result\u003c(), Box\u003cdyn std::error::Error\u003e\u003e {\n\tlet model = create_model(\n\t\tinclude_bytes!(concat!(env!(\"CARGO_MANIFEST_DIR\"), \"/model.onnx\"))\n\t);\n\n\tlet image = image::open(concat!(env!(\"CARGO_MANIFEST_DIR\"), \"/might_be_porn.jpg\"))?;\n\tlet result = examine(\u0026model, \u0026image)?;\n\tprintln!(\"{:#?}\", result);\n\n\tOk(())\n}\n```\n\n## Example: GIF\n\n```toml\n[dependencies]\nimage = { version = \"0.24.7\", default-features = false, features = [\"gif\"] }\nnsfw = { version = \"0.1.0\", default-features = false, features = [\"gif\"] }\n```\n\n```rust,no_test\nuse nsfw::{examine, MODEL, GifParser};\n\nfn main() -\u003e Result\u003c(), Box\u003cdyn std::error::Error\u003e\u003e {\n\tlet model = create_model(\n\t\tinclude_bytes!(concat!(env!(\"CARGO_MANIFEST_DIR\"), \"/model.onnx\"))\n\t);\n\n\tlet path = concat!(env!(\"CARGO_MANIFEST_DIR\"), \"/might_be_porn.gif\");\n\tlet file = BufReader::new(File::open(gif_path)?);\n\tlet frames = GifParser::new(GifDecoder::new(file)?, \u0026model);\n\n\tfor frame in frames {\n\t\tprintln!(\"{frame:#?}\")\n\t}\n\n\tOk(())\n}\n```\n\n## Feature Flags\n\n- `default` - `jpeg` and `png`\n- `serde` - Enables serialization and deserialization of the model using [`serde`].\n- `gif` - Enables GIF support for [`image`].\n- `jpeg` - Enables JPEG support for [`image`].\n- `png` - Enables PNG support for [`image`].\n- `webp` - Enables WEBP support for [`image`].\n\n## Benchmarking\n\n| Name          | Size                          | Language                                | Time             |\n| ------------- | ----------------------------- | --------------------------------------- | ---------------- |\n| test_porn.gif | `50495726` bytes (`50.49` MB) | [Rust](./src/gif.rs#L61)                | `22.719` seconds |\n| test_porn.gif | `50495726` bytes (`50.49` MB) | [JavaScript](./test/node/nsfw_bench.js) | `219.96` seconds |\n\n[crates.io]: https://img.shields.io/crates/v/nsfw.svg\n[Documentation]: https://docs.rs/nsfw/badge.svg\n[Build Status]: https://github.com/Fyko/nsfw/actions/workflows/test.yml/badge.svg\n[Discord]: https://img.shields.io/discord/1041931589631881257?color=5865F2\u0026logo=discord\u0026logoColor=white\n[GantMan's model]: https://github.com/GantMan/nsfw_model\n[the release page]: https://github.com/Fyko/nsfw/releases/latest\n[ONNX]: https://onnx.ai/\n[GitHub Workflow]: https://github.com/Fyko/nsfw/actions/workflows/create_model.yml\n[`serde`]: https://crates.pm/serde\n[`image`]: https://crates.pm/image\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffyko%2Fnsfw","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffyko%2Fnsfw","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffyko%2Fnsfw/lists"}