mirror of
https://github.com/jantic/DeOldify.git
synced 2026-09-01 15:36:32 +08:00
127 lines
3.5 KiB
Plaintext
127 lines
3.5 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"import os\n",
|
|
"os.environ['CUDA_VISIBLE_DEVICES']='0' "
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"from fasterai.visualize import *\n",
|
|
"plt.style.use('dark_background')\n",
|
|
"torch.backends.cudnn.benchmark=True"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"#Adjust render_factor (int) if image doesn't look quite right (max 45 on 11GB GPU). \n",
|
|
"#Lower render factors (as low as 12-15) tend to work well for old and low quality videos.\n",
|
|
"#High render factors (25-45) tend to work well for higher quality and more recent videos\n",
|
|
"\n",
|
|
"#Not satisfied with color saturation? Lower the render factor. \n",
|
|
"#Unacceptable object flicker? Increase the render factor.\n",
|
|
"\n",
|
|
"#It literally just is a number multiplied by 16 to get the square render resolution. \n",
|
|
"#Note that this doesn't affect the resolution of the final output- the output is the same resolution as the input.\n",
|
|
"#Example: render_factor=21 => color is rendered at 16x21 = 336x336 px. \n",
|
|
"render_factor=21\n",
|
|
"#Specify media_url. Many sources will work (YouTube, Imgur, Twitter, Reddit, etc). \n",
|
|
"#Complete list here: https://rg3.github.io/youtube-dl/supportedsites.html. \n",
|
|
"#NOTE: Make source_url None to just read from file at ./video/source/[file_name] directly without modification\n",
|
|
"#source_url= 'https://twitter.com/silentmoviegifs/status/1112256563182489600'\n",
|
|
"#source_url='https://archive.org/details/impact'\n",
|
|
"source_url='https://twitter.com/silentmoviegifs/status/1116751583386034176'\n",
|
|
"file_name = 'DogBath.mp4'"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"colorizer = get_video_colorizer()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"if source_url is not None:\n",
|
|
" video_path = colorizer.colorize_from_url(source_url, file_name, render_factor=render_factor)\n",
|
|
" show_video_in_notebook(video_path)\n",
|
|
"else:\n",
|
|
" video_path = colorizer.colorize_from_file_name(file_name)\n",
|
|
" show_video_in_notebook(video_path)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": []
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "Python 3",
|
|
"language": "python",
|
|
"name": "python3"
|
|
},
|
|
"language_info": {
|
|
"codemirror_mode": {
|
|
"name": "ipython",
|
|
"version": 3
|
|
},
|
|
"file_extension": ".py",
|
|
"mimetype": "text/x-python",
|
|
"name": "python",
|
|
"nbconvert_exporter": "python",
|
|
"pygments_lexer": "ipython3",
|
|
"version": "3.7.0"
|
|
},
|
|
"toc": {
|
|
"colors": {
|
|
"hover_highlight": "#DAA520",
|
|
"navigate_num": "#000000",
|
|
"navigate_text": "#333333",
|
|
"running_highlight": "#FF0000",
|
|
"selected_highlight": "#FFD700",
|
|
"sidebar_border": "#EEEEEE",
|
|
"wrapper_background": "#FFFFFF"
|
|
},
|
|
"moveMenuLeft": true,
|
|
"nav_menu": {
|
|
"height": "67px",
|
|
"width": "252px"
|
|
},
|
|
"navigate_menu": true,
|
|
"number_sections": true,
|
|
"sideBar": true,
|
|
"threshold": 4,
|
|
"toc_cell": false,
|
|
"toc_section_display": "block",
|
|
"toc_window_display": false,
|
|
"widenNotebook": false
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 2
|
|
}
|