{"id":17017445,"url":"https://github.com/ntaraujo/gse","last_synced_at":"2026-04-02T02:36:48.509Z","repository":{"id":53612593,"uuid":"314669782","full_name":"ntaraujo/gse","owner":"ntaraujo","description":"Green Screen Emulator: A.I. changing the background of your video/image","archived":false,"fork":false,"pushed_at":"2023-01-31T22:13:07.000Z","size":318,"stargazers_count":14,"open_issues_count":1,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-26T04:34:47.391Z","etag":null,"topics":["image-processing","moviepy","pytorch","pytorch-implementation","video-processing"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ntaraujo.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}},"created_at":"2020-11-20T21:08:48.000Z","updated_at":"2025-03-22T19:31:53.000Z","dependencies_parsed_at":"2023-02-16T23:31:29.199Z","dependency_job_id":null,"html_url":"https://github.com/ntaraujo/gse","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ntaraujo%2Fgse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ntaraujo%2Fgse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ntaraujo%2Fgse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ntaraujo%2Fgse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ntaraujo","download_url":"https://codeload.github.com/ntaraujo/gse/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248547463,"owners_count":21122512,"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":["image-processing","moviepy","pytorch","pytorch-implementation","video-processing"],"created_at":"2024-10-14T06:36:40.204Z","updated_at":"2026-04-02T02:36:48.480Z","avatar_url":"https://github.com/ntaraujo.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Green Screen Emulator\nThis project is based on [Deep BGRemove](https://github.com/WhiteNoise/deep-bgremove)\n\n![example](https://user-images.githubusercontent.com/66187211/100396165-d544a880-3022-11eb-8996-dfcf3faea716.gif)\n\n## Current features\n* Work with video/image with people\n* Output a mask you can use in another editor\n* Output the video/image with the background already modified by a video/image/color\n* Apply a mask of your choice instead the A.I. generated one (e.g. a previous exported mask with this app)\n* Use as module, API\n* Graphical interface\n\n## To do\n* Improve time spent\n* Work with more than just people images, but also objects and animals\n* Complete graphical interface\n* Windows executable\n* Save projects to decrease processing time on multiple requests\n* Improve configuration file experience and options\n\n## Quickstart\nClone this repo:\n```sh\ngit clone https://github.com/ntaraujo/gse.git\ncd gse\n```\n\nIf you haven't, install python in your machine. Preferably [this release](https://www.python.org/downloads/release/python-386/)\n\nFollow [these](https://pytorch.org/get-started/locally/) instructions to install PyTorch locally (you can omit torchaudio if you wish)\n\nE.g. the command to install the current PyTorch version for Windows and Linux with the Pip package manager and no CUDA features (not so cool):\n```sh\npip install torch==1.7.0+cpu torchvision==0.8.1+cpu -f https://download.pytorch.org/whl/torch_stable.html\n```\nThen install MoviePy and Dill\n```sh\npip install moviepy dill\n```\n\nSince PyTorch cannot be installed with pip in the same way on all platforms, `requirements.txt` serves as a reference for the package versions that have been tested.\n\n## Use with the graphical interface\nInstall [kivy](https://kivy.org/doc/stable/gettingstarted/installation.html) and\n[kivymd](https://github.com/kivymd/KivyMD) at least 0.104.2\n([why](https://stackoverflow.com/questions/61307599/filemanager-code-using-kivymd-is-not-functioning)).\nE.g. on linux at the time of writing:\n```sh\npip install kivy[base] https://github.com/kivymd/KivyMD/archive/master.zip\n```\n\nRun main.py:\n```sh\npython main.py\n```\n\n## Use with a configuration file\nRename `config.json.example` to `config.json` and edit the values to which attend your needs.\nE.g. on Linux:\n```sh\nmv config.json.example config.json\nxdg-open config.json\n```\n\nThe file to run in this case is `gse.py`\n```sh\npython gse.py\n```\n\n## Basics of configuration file / variables\n* __input__: The path to your existent video/image. The format must be supported by MoviePy. E.g. `\"old_one.mp4\"`\n\n* __output_dir__: Directory for outputting videos, images, temporary files and/or logs. Need a \"/\" or \"\\\\\" in the end. E.g `\"/home/user/Videos/\"`. If `\"\"`, defaults to current directory\n\n* __output_name__: Part of the generated file name. This will be {output_name}.{extension} if `get_frame` is `0`. E.g. `\"new_one\"`\n\n* __extension__: Video/image formats supported by MoviePy. If video, must correspond to `video_codec` and `input` must also to be a video. If image, `input` must to be an image. E.g `\"mp4\"` and `\"jpg\"`\n\n* __background__: Path to an image or RGB color or also video if `input` is a video. If `\"\"` the output is a black and white mask you can use in another editor. RGB colors are typed in square brackets and with commas between parameters: `[R, G, B]`. E.g. `[0, 255, 0]` (green screen) and `\"path/to/my/image.jpg\"`\n\n* __relative_mask_resolution__: Depending on how big your `input` is, you may want to decrease the time spent analyzing it. This will not decrease the final output resolution but the quality and accuracy of the mask. E.g. `80` (%, percent)\n\n* __relative_mask_fps__: For the same reasons you may want to decrease the amount of frames in your video `input` that will be computed. This will not decrease the final fps of the person in scene or even the background fps. What is affected is how fluid is the movement of the mask that accompanies the person movement. Typically, if you have a 60fps video you can use a 30fps mask without noticeable changes on the video quality. E.g. `50` (%, percent)\n\n* __get_frame__: If you want a preview of the processing results (mainly the `relative_mask_resolution` setting) in your video `input`, set this variable to a number greater than 0. This will be the frame number exported as {output_dir}{output_name}.jpg. E.g. `535`\n\n## Use with IPython Notebook or Python Console\nCan be useful if you want to save time, since when the program is run it loads a lot of stuff which will only be used with a single configuration file, a single output.\nFull docs [here](https://github.com/ntaraujo/gse/blob/master/gse.py)\n```python\nimport gse\n\np = gse.Project()  # load with no configuration\n\np = gse.Project(\"config.json\")  # load with a configuration file\n\np.load(\"my_project.gse\")  # replace the Project variables with previous saved ones\n\np.processes()  # do all at once\n\np.relative_mask_fps = 60  # Modify a single configuration variable\n\n# Load the input file and let it available as p.input_clip\np.processes(0)\n\n# Change the video duration to 6 seconds\n# See what is possible at https://zulko.github.io/moviepy/ref/VideoClip/VideoClip.html\np.input_clip = p.input_clip.set_duration(6)\n\n# Load the mask and let it available as p.mask_clip\np.processes(1)\n\n# Add a 2-second fade in effect to the mask\n# See other effects in https://zulko.github.io/moviepy/ref/videofx.html\nfrom moviepy.video.fx.fadein import fadein\np.mask_clip = p.mask_clip.fx(fadein, 2)\n\n# Make the final clip based on the background choice and let it available as p.final_clip\np.processes(2)\n\n# Check the final clip duration\nprint(p.final_clip.duration)\n\n# Export to file\np.processes(3)\n\n# Use another mask with another resolution, without changing the class variables\np.processes((1, 2, 3),\n            mask=\"video_with_beautiful_shapes.mp4\",\n            relative_mask_resolution=61)\n\n# Change the background \u0026 the class variables\np.processes((2, 3), local=False, background=[0, 0, 255])\n\n# Just export a preview of the video, with the same mask, input and background\np.processes(3, get_frame=578)\n\n# In IPython Notebook you can also preview with the following, where t is measured in seconds\np.final_clip.ipython_display(t=15)\n\n# Note that for video, the longest time is spent in gse.save_to_file() or\n# gse.Project.process(3), so there is no much to do for saving this time\n\n# Save the entire Project to use after\np.save(\"my_project.gse\")\n```\n\n## Some examples\n\n### Masks computed with 384x216 resolution\n| Example 1 | Example 2 |\n| --------- | --------- |\n| ![example1](https://user-images.githubusercontent.com/66187211/100396393-86e3d980-3023-11eb-90b8-06ca36d6287f.gif) | ![example2](https://user-images.githubusercontent.com/66187211/100396465-d75b3700-3023-11eb-8a34-36223b97d3ef.gif) |\n\n### Background substitution (2160x4096)\n| Original | Color | Image |\n| -------- | ----- | ----- |\n| ![original](https://user-images.githubusercontent.com/66187211/100396444-c4486700-3023-11eb-811a-141586f6357a.jpg) | ![color](https://user-images.githubusercontent.com/66187211/100396447-c5799400-3023-11eb-8fd7-b416821680e8.jpg) | ![image](https://user-images.githubusercontent.com/66187211/100396449-c6122a80-3023-11eb-8ad7-f1fcff976d01.jpg) |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fntaraujo%2Fgse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fntaraujo%2Fgse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fntaraujo%2Fgse/lists"}