DEV Community

0xkoji
0xkoji

Posted on β€’ Edited on

15

Download Files From Google Drive With curl/wget

Sometimes we need to use curl/wget to download files from Google Drive from scripts. In terms of small file, we don't have any issues, but on the other hand, with a big file(especially download pre-trained model) needs to download the file manually which is very annoyed.

In this my last post in 2019, I'll show you how to avoid downloading files manually.

Small file

https://drive.google.com/file/d/0B-0p-MTxJBSCU2lwaGNUZ3VYSG8/view?usp=sharing

This is my Processing sketch and the size of the file is 2MB.
In the link, 0B-0p-MTxJBSCU2lwaGNUZ3VYSG8 is fileId

$ wget "https://drive.google.com/uc?export=download&id=<fileId>" -O <fileName>
Enter fullscreen mode Exit fullscreen mode
$ wget "https://drive.google.com/uc?export=download&id=0B-0p-MTxJBSCU2lwaGNUZ3VYSG8" -O myProcessing_sketch.mp4
Enter fullscreen mode Exit fullscreen mode

Alt Text

Big file

In terms of a big file, the way to download is a little bit complicated since Google Drive tries to scan the file to make things secure.

In this case, we will try to download M2Det's pre-trained model.

GitHub logo VDIGPKU / M2Det

M2Det: A Single-Shot Object Detector based on Multi-Level Feature Pyramid Network

M2Det

Codebase for AAAI2019 "M2Det: A Single-Shot Object Detector based on Multi-Level Feature Pyramid Network" [Paper link]

Author: Qijie Zhao. Date: 19/01/2019

Contents

Introduction

Motivation:

Beyond scale variation, appearance-complexity variation should be considered too for the object detection task, due to that the object instances with similar size can be quite different.

To solve this, we extend multi-scale detection fashions with a new dimension: multi-level. Deeper level learns features for objects with more appearance-complexity variation(e.g., pedestrian), while shallower level learns features for more simplistic objects(e.g., traffic light).

1, We propose Multi Level FPN:

2, Based on MLFPN, we propose a single-shot object detector: M2Det, which represents the Multi-Level Multi-Scale Detector.

Methodology:

a. Construct the base feature:

We use the output of FFMv1(Feature Fusion Module v1) to construct the base feature. The size is fixed as…













To download a big file, we will need 4 digits which are code in a shell script. Then we also need fileId and fileName as well.

# https://drive.google.com/file/d/1NM1UDdZnwHwiNDxhcP-nndaWj24m-90L/view
fileId=1NM1UDdZnwHwiNDxhcP-nndaWj24m-90L
fileName=m2det512_vgg.pth
curl -sc /tmp/cookie "https://drive.google.com/uc?export=download&id=${fileId}" > /dev/null
code="$(awk '/_warning_/ {print $NF}' /tmp/cookie)"  
curl -Lb /tmp/cookie "https://drive.google.com/uc?export=download&confirm=${code}&id=${fileId}" -o ${fileName} 
Enter fullscreen mode Exit fullscreen mode

Happy New Year from NYC

Buy Me A Coffee

Playwright CLI Flags Tutorial

5 Playwright CLI Flags That Will Transform Your Testing Workflow

  • 0:56 --last-failed
  • 2:34 --only-changed
  • 4:27 --repeat-each
  • 5:15 --forbid-only
  • 5:51 --ui --headed --workers 1

Learn how these powerful command-line options can save you time, strengthen your test suite, and streamline your Playwright testing experience. Click on any timestamp above to jump directly to that section in the tutorial!

Watch Full Video πŸ“ΉοΈ

Top comments (2)

Collapse
 
christianbueno1 profile image
Christian Bueno β€’

Thanks pal, very useful information, go ahead.

Collapse
 
0xkoji profile image
0xkoji β€’

thanks!

Eliminate Context Switching and Maximize Productivity

Pieces.app

Pieces Copilot is your personalized workflow assistant, working alongside your favorite apps. Ask questions about entire repositories, generate contextualized code, save and reuse useful snippets, and streamline your development process.

Learn more

πŸ‘‹ Kindness is contagious

Engage with a wealth of insights in this thoughtful article, valued within the supportive DEV Community. Coders of every background are welcome to join in and add to our collective wisdom.

A sincere "thank you" often brightens someone’s day. Share your gratitude in the comments below!

On DEV, the act of sharing knowledge eases our journey and fortifies our community ties. Found value in this? A quick thank you to the author can make a significant impact.

Okay