{"id":15354524,"url":"https://github.com/athen-lab/mai","last_synced_at":"2025-04-15T06:11:23.027Z","repository":{"id":236398463,"uuid":"792526232","full_name":"athen-lab/mai","owner":"athen-lab","description":"Multilayer Authenticity Identifier (MAI), a CNN model that attempts to identify synthetic AI images.","archived":false,"fork":false,"pushed_at":"2025-02-15T20:10:13.000Z","size":255,"stargazers_count":28,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-28T16:51:17.453Z","etag":null,"topics":["cnn","cnn-classification","cnn-model","machine-learning","pytorch"],"latest_commit_sha":null,"homepage":"","language":"Python","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/athen-lab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2024-04-26T21:20:24.000Z","updated_at":"2025-02-15T20:10:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"506c4f29-6891-4721-a607-9b23589d7d9c","html_url":"https://github.com/athen-lab/mai","commit_stats":null,"previous_names":["kennethnym/mai","athen-lab/mai"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/athen-lab%2Fmai","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/athen-lab%2Fmai/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/athen-lab%2Fmai/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/athen-lab%2Fmai/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/athen-lab","download_url":"https://codeload.github.com/athen-lab/mai/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249016627,"owners_count":21198833,"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":["cnn","cnn-classification","cnn-model","machine-learning","pytorch"],"created_at":"2024-10-01T12:19:36.295Z","updated_at":"2025-04-15T06:11:23.013Z","avatar_url":"https://github.com/athen-lab.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Multilayer Authenticity Identifier (MAI)\n\nMAI is a research project that attempts to train a machine learning model that identifies AI-generated images.\n\n## Why?\n\ni am bored.\n\n## Architecture\n\ni have experimented with the following model architectures with varying degrees of success.\nthey reside in their own directory.\n\n### convolutional neural network (CNN)\n\nthe code for the CNN model is located at `./resnet`.\n\nthe CNN model looks like this:\n\n1. 16-channel, 3x3 convolution layer -\u003e 2x2 max pooling -\u003e relu activation\n2. 32-channel, 3x3 convolution layer -\u003e 2x2 max pooling -\u003e relu activation\n3. 64-channel, 3x3 convolution layer -\u003e 2x2 max pooling -\u003e relu activation\n4. 40,000-neuron layer -\u003e relu -\u003e 120-neuron layer -\u003e relu -\u003e 30 -\u003e 1\n\nthe model expects a 200x200 image as an input and outputs a score, with 1 being that the input image is absolutely synthetic, and 0 being that it is absolutely authentic.\n\n[BCEWithLogitLoss](https://pytorch.org/docs/stable/generated/torch.nn.BCEWithLogitsLoss.html) is used as the loss fn, and [RMSprop](https://pytorch.org/docs/stable/generated/torch.optim.RMSprop.html) as the optimizer.\n\n### vision language model (VLM)\n\nthe code for the vlm model finetuning is located at `./moondream`.\n\nfollowing [the Bi-LoRA paper](https://arxiv.org/abs/2404.01959) which suggests finetuning a vlm on real and ai-generated images, i decided to finetune [moondream](https://moondream.ai/), a small vlm.\n\nthe training data consists of 50% real images and 50% ai-generated images, along with a q\u0026a pair.\nthe question is always \"Is this image AI-generated?\", followed by the answer \"Yes.\" or \"No.\", depending on whether the image is ai-generated or not.\n\npreliminary experiments show mixed results. to improve the training data, i decided to generate my own dataset using the following steps:\n\n1. ask moondream to caption a real image.\n2. use that caption to prompt a model (stable diffusion 3.5 large at the moment) to generate the equivalent ai image.\n3. add the image to the row alongside the real image.\n\nhopefully, this will help moondream better understand the difference between real and ai-generated images.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fathen-lab%2Fmai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fathen-lab%2Fmai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fathen-lab%2Fmai/lists"}