Skip to content

Commit

Permalink
添加GPU开关
Browse files Browse the repository at this point in the history
  • Loading branch information
dream80 committed Jun 8, 2023
1 parent 628a5a9 commit 23e8859
Showing 1 changed file with 69 additions and 13 deletions.
82 changes: 69 additions & 13 deletions ROOP:一张图片一键换脸.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
"provenance": [],
"machine_shape": "hm",
"gpuType": "T4",
"mount_file_id": "15zAC6KgPk6A8NCypGHIyUgYp3q1bfDuU",
"authorship_tag": "ABX9TyMqz8m0Qy+4Tnsk/Ary1Fz/",
"collapsed_sections": [
"klzSfQPfwSNV"
],
"authorship_tag": "ABX9TyMR8mfYYgsBG/AN5wfdukX6",
"include_colab_link": true
},
"kernelspec": {
Expand Down Expand Up @@ -109,7 +111,15 @@
"cell_type": "code",
"source": [
"#@title 5.开始换脸\n",
"!python run.py --gpu-vendor nvidia -f /content/roop_colab/1.jpg -t /content/roop_colab/2.mp4 -o /content/roop_colab/out.mp4"
"\n",
"GPU = True #@param {type:\"boolean\"}\n",
"\n",
"if GPU : \n",
" !python run.py --gpu-vendor nvidia -f /content/roop_colab/1.jpg -t /content/roop_colab/2.mp4 -o /content/roop_colab/out.mp4\n",
"else:\n",
" !python run.py -f /content/roop_colab/1.jpg -t /content/roop_colab/2.mp4 -o /content/roop_colab/out.mp4\n",
"\n",
"\n"
],
"metadata": {
"id": "cMJi9bI3LUyX",
Expand All @@ -118,37 +128,83 @@
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"勾选GPU,则使用GPU,如果你GPU配额用完了,可以去掉勾选,用CPU顶一下。或者开Pro+"
],
"metadata": {
"id": "iOOzIywkxw9o"
}
},
{
"cell_type": "markdown",
"source": [
"#补充说明\n",
"\n",
"### 视频文件在哪里? \n",
" \n"
],
"metadata": {
"id": "P_cIVG84cTX3"
}
},
{
"cell_type": "markdown",
"source": [
"\n",
"换脸成功后的视频保存在roop_colab文件里面 \n",
"## 视频文件在哪里? \n",
"\n",
" \n",
"### 如何提花你自己的素材 \n",
"换脸成功后的视频保存在roop_colab文件里面 \n"
],
"metadata": {
"id": "O8qkUHNNw8-z"
}
},
{
"cell_type": "markdown",
"source": [
"## 如何使用自己的素材? \n",
"\n",
"如果要替换图片和视频,只需要在左边的文件管理里面右键上传,然后改一下名字就可以了\n",
"如果要替换图片和视频,只需要在左边的文件管理里面右键上传,然后改一下名字就可以。了\n",
"素材文件都在roop_colab文件中 \n",
"1.jpg:换脸图片 \n",
"2.mp4:换脸视频 \n",
"out.mp4:是换脸后的视频 \n",
"\n",
"点击左侧文件,找到MP4,右键可以下载!\n",
"\n"
],
"metadata": {
"id": "pl3m7Ymmw3A8"
}
},
{
"cell_type": "markdown",
"source": [
"## 解除NSFW封印\n",
"\n",
"如果第五步没有成功,大概率是被监测到涩涩了。 \n",
"在左边目文件管理里面找到roop/core.py,双击打开找到 predict_video_frames,predict_image相关的行和quit()函数删掉就可以了。"
],
"metadata": {
"id": "kUXiEHjCxMpt"
}
},
{
"cell_type": "markdown",
"source": [
"\n",
"### 大文件处理\n",
"## 大文件处理\n",
"\n",
"如果文件比较大,直接在Colab上传会有难度,可以先传到谷歌云盘。然后挂载云盘就可以了,修改一下第五步里面图片和视频的地址就可以了。\n",
"如果文件比较大,直接在Colab上传会有难度,可以先传到谷歌云盘。然后挂载云盘就可以了,修改一下第五步里面图片和视频的地址就可以了。挂载谷歌盘之后也可以把输出文件直接指向云盘。 \n",
"\n",
"如何需要使用谷歌云盘的文件,可以点击这个脚本,挂载云盘。\n",
"\n",
"### 第五步没有成功(被监测到涩涩了) \n",
"在左边目文件管理里面找到roop/core.py,双击打开找到 predict_video_frames,predict_image相关的行和quit()函数删掉就可以了。\n"
"from google.colab import drive \n",
"drive.mount('/content/drive')"
],
"metadata": {
"id": "P_cIVG84cTX3"
"id": "klzSfQPfwSNV"
}
}
]
Expand Down

0 comments on commit 23e8859

Please sign in to comment.