change googledrivedownloader to gdown
This commit is contained in:
+16
-21
@@ -127,9 +127,7 @@
|
||||
"outputId": "9691a7a4-192e-4ec2-c3c1-1f2c933d7b6a"
|
||||
},
|
||||
"source": [
|
||||
"!pip install insightface==0.2.1 onnxruntime moviepy\n",
|
||||
"!pip install googledrivedownloader\n",
|
||||
"!pip install imageio==2.4.1"
|
||||
"!pip install insightface==0.2.1 onnxruntime imageio==2.4.1"
|
||||
],
|
||||
"execution_count": 3,
|
||||
"outputs": [
|
||||
@@ -224,13 +222,9 @@
|
||||
"outputId": "e93c3f98-01df-458e-b791-c32f7343e705"
|
||||
},
|
||||
"source": [
|
||||
"from google_drive_downloader import GoogleDriveDownloader\n",
|
||||
"\n",
|
||||
"### it seems that google drive link may not be permenant, you can find this ID from our open url.\n",
|
||||
"# GoogleDriveDownloader.download_file_from_google_drive(file_id='1TLNdIufzwesDbyr_nVTR7Zrx9oRHLM_N',\n",
|
||||
"# dest_path='./arcface_model/arcface_checkpoint.tar')\n",
|
||||
"# GoogleDriveDownloader.download_file_from_google_drive(file_id='1PXkRiBUYbu1xWpQyDEJvGKeqqUFthJcI',\n",
|
||||
"# dest_path='./checkpoints.zip')\n",
|
||||
"# !mkdir arcface_model && gdown --id 1TLNdIufzwesDbyr_nVTR7Zrx9oRHLM_N -O ./arcface_model/arcface_checkpoint.tar\n",
|
||||
"# !gdown --id 1PXkRiBUYbu1xWpQyDEJvGKeqqUFthJcI -O checkpoints.zip\n",
|
||||
"\n",
|
||||
"!wget -P ./arcface_model https://github.com/neuralchen/SimSwap/releases/download/1.0/arcface_checkpoint.tar\n",
|
||||
"!wget https://github.com/neuralchen/SimSwap/releases/download/1.0/checkpoints.zip\n",
|
||||
@@ -277,7 +271,7 @@
|
||||
"### open url(can be found at [our repo]/doc/guidance/preparation.md) and copy the assigned download link here.\n",
|
||||
"### many thanks to woctezuma for this very useful help\n",
|
||||
"!wget --no-check-certificate \"https://sh23tw.dm.files.1drv.com/y4mmGiIkNVigkSwOKDcV3nwMJulRGhbtHdkheehR5TArc52UjudUYNXAEvKCii2O5LAmzGCGK6IfleocxuDeoKxDZkNzDRSt4ZUlEt8GlSOpCXAFEkBwaZimtWGDRbpIGpb_pz9Nq5jATBQpezBS6G_UtspWTkgrXHHxhviV2nWy8APPx134zOZrUIbkSF6xnsqzs3uZ_SEX_m9Rey0ykpx9w\" -O antelope.zip\n",
|
||||
"!unzip ./antelope.zip -d ./insightface_func/models/\n"
|
||||
"!unzip ./antelope.zip -d ./insightface_func/models/"
|
||||
],
|
||||
"execution_count": 6,
|
||||
"outputs": [
|
||||
@@ -358,6 +352,7 @@
|
||||
"from IPython.display import HTML\n",
|
||||
"from base64 import b64encode\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def show_mp4(filename, width=720):\n",
|
||||
" mp4 = open(filename, 'rb').read()\n",
|
||||
" data_url = \"data:video/mp4;base64,\" + b64encode(mp4).decode()\n",
|
||||
@@ -365,7 +360,7 @@
|
||||
" <video width=\"%d\" controls autoplay loop>\n",
|
||||
" <source src=\"%s\" type=\"video/mp4\">\n",
|
||||
" </video>\n",
|
||||
" \"\"\" % (width, data_url))) "
|
||||
" \"\"\" % (width, data_url)))"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -376,7 +371,7 @@
|
||||
"source": [
|
||||
"transformer = transforms.Compose([\n",
|
||||
" transforms.ToTensor(),\n",
|
||||
" #transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])\n",
|
||||
" # transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])\n",
|
||||
" ])\n",
|
||||
"\n",
|
||||
"transformer_Arcface = transforms.Compose([\n",
|
||||
@@ -404,10 +399,10 @@
|
||||
"source": [
|
||||
"opt = TestOptions()\n",
|
||||
"opt.initialize()\n",
|
||||
"opt.parser.add_argument('-f') ## dummy arg to avoid bug\n",
|
||||
"opt.parser.add_argument('-f') # dummy arg to avoid bug\n",
|
||||
"opt = opt.parse()\n",
|
||||
"opt.pic_a_path = './demo_file/Iron_man.jpg' ## or replace it with image from your own google drive\n",
|
||||
"opt.video_path = './demo_file/multi_people_1080p.mp4' ## or replace it with video from your own google drive\n",
|
||||
"opt.pic_a_path = './demo_file/Iron_man.jpg' # or replace it with image from your own google drive\n",
|
||||
"opt.video_path = './demo_file/multi_people_1080p.mp4' # or replace it with video from your own google drive\n",
|
||||
"opt.output_path = './output/demo.mp4'\n",
|
||||
"opt.temp_path = './tmp'\n",
|
||||
"opt.Arc_path = './arcface_model/arcface_checkpoint.tar'\n",
|
||||
@@ -421,27 +416,27 @@
|
||||
"\n",
|
||||
"\n",
|
||||
"app = Face_detect_crop(name='antelope', root='./insightface_func/models')\n",
|
||||
"app.prepare(ctx_id= 0, det_thresh=0.6, det_size=(640,640))\n",
|
||||
"app.prepare(ctx_id=0, det_thresh=0.6, det_size=(640, 640))\n",
|
||||
"\n",
|
||||
"pic_a = opt.pic_a_path\n",
|
||||
"# img_a = Image.open(pic_a).convert('RGB')\n",
|
||||
"img_a_whole = cv2.imread(pic_a)\n",
|
||||
"img_a_align_crop, _ = app.get(img_a_whole,crop_size)\n",
|
||||
"img_a_align_crop_pil = Image.fromarray(cv2.cvtColor(img_a_align_crop[0],cv2.COLOR_BGR2RGB)) \n",
|
||||
"img_a_align_crop, _ = app.get(img_a_whole, crop_size)\n",
|
||||
"img_a_align_crop_pil = Image.fromarray(cv2.cvtColor(img_a_align_crop[0], cv2.COLOR_BGR2RGB))\n",
|
||||
"img_a = transformer_Arcface(img_a_align_crop_pil)\n",
|
||||
"img_id = img_a.view(-1, img_a.shape[0], img_a.shape[1], img_a.shape[2])\n",
|
||||
"\n",
|
||||
"# convert numpy to tensor\n",
|
||||
"img_id = img_id.cuda()\n",
|
||||
"\n",
|
||||
"#create latent id\n",
|
||||
"# create latent id\n",
|
||||
"img_id_downsample = F.interpolate(img_id, scale_factor=0.5)\n",
|
||||
"latend_id = model.netArc(img_id_downsample)\n",
|
||||
"latend_id = latend_id.detach().to('cpu')\n",
|
||||
"latend_id = latend_id/np.linalg.norm(latend_id,axis=1,keepdims=True)\n",
|
||||
"latend_id = latend_id/np.linalg.norm(latend_id, axis=1, keepdims=True)\n",
|
||||
"latend_id = latend_id.to('cuda')\n",
|
||||
"\n",
|
||||
"video_swap(opt.video_path, latend_id, model, app, opt.output_path,temp_results_dir=opt.temp_path)"
|
||||
"video_swap(opt.video_path, latend_id, model, app, opt.output_path, temp_results_dir=opt.temp_path)"
|
||||
],
|
||||
"execution_count": 9,
|
||||
"outputs": [
|
||||
|
||||
Reference in New Issue
Block a user