question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Guide?] How to run v4.5 on google colab

See original GitHub issue

zbiarita

I hate anything which come along with a fat framework, especially when those extra ~600mb garbage is just for an unnecessary purpose. So I made some tweaks to make v4.5 run on google colab. If you also want to avoid this totally unoptimized thing cooking your pc, you might be interested.

Unfortunately, I can’t provide you guys full code cuz the author of this is clearly willing to keep something in “secret” by obfuscating his codes. ( scriptkiddie-tier dumb obfuscation, tho )

Here are the steps:

    1. Fork the v4.5 gdrive release to your own gdrive.
    1. Make a colab notebook, mount gdrive, insert 1st code block like this:
import os
!unzip '/content/drive/My Drive/<your path>/Style2PaintsV45配布/style2paints45beta1214B.zip' > 00.txt
os.rename('/content/style2paints45beta1214B/assets/nets','/content/nets')
os.rename('/content/style2paints45beta1214B/assets/game','/content/game')
os.rename('/content/style2paints45beta1214B/assets/gpu.conf','/content/gpu.conf')

run it.

    1. Modify /content/game/src/project.js, remove all ‘window.server_url+’ string in it, or just replace it with the attachment. project.txt
    1. Get the decompiled v4.5 code by some mean. As you see a decompiled script starts with ‘def main_exec():’, and full of sh*t like OO0O000OO000OOO00(op), that’s it. Paste the decompiled code to 2nd code block.
    1. Erase all the import xxx, from xxx import xxxx in the 2nd code, replace all ‘8233’ with ‘viewppp’, paste
%tensorflow_version 1.x
!pip install bottle
import sys
import socket, os
import tensorflow as tf
import numpy as np, datetime, pickle, base64, json, gzip, re, os, shutil
import cv2
from tensorflow.python.client import device_lib
from threading import Thread
from google.colab.output import eval_js
from tqdm import tqdm
from cv2.ximgproc import l0Smooth, createGuidedFilter, guidedFilter
from bottle import route, run, static_file, request, BaseRequest

BaseRequest.MEMFILE_MAX = 10000000


def replaceservname(servaddr):
  data=[]
  with open('/content/game/src/project.js','rt') as fjs:
    data=fjs.read()
    data=data.replace('http://127.0.0.1:8233',servaddr)
  with open('/content/game/src/project.js','wt') as fjs:
    fjs.write(data)
   
def main_exec(viewppp):
    ruul = eval_js( 'google.colab.kernel.proxyPort(' + str(viewppp) +')')[:-1]
    print(ruul+'/index.html')
    replaceservname(ruul)

to 2nd code’s head (overwrite first line of def main_exec()😃

    1. Comment out these lines:
os.system('start ./dotnet/Style2Paints.exe')
Thread(target=O0000O0OO0O0000O0, args=('Now Loading ...', )).start()

        if os.path.exists('_pywrap_tensorflow_internal_gpu.pyd'):
            if os.path.exists('_pywrap_tensorflow_internal.pyd'):
                shutil.move('_pywrap_tensorflow_internal.pyd', '_pywrap_tensorflow_internal_cpu.pyd')
            shutil.move('_pywrap_tensorflow_internal_gpu.pyd', '_pywrap_tensorflow_internal.pyd')
        else:
            print('Style2Paints Customed Tensorflow Shifting to CPU.')
            if os.path.exists('_pywrap_tensorflow_internal_cpu.pyd'):
                if os.path.exists('_pywrap_tensorflow_internal.pyd'):
                    shutil.move('_pywrap_tensorflow_internal.pyd', '_pywrap_tensorflow_internal_gpu.pyd')
                shutil.move('_pywrap_tensorflow_internal_cpu.pyd', '_pywrap_tensorflow_internal.pyd')
                
    1. Run 2nd code block, make 3rd code block with
main_exec(8233)
  1. Run 3rd code block, after message like
Listening on http://0.0.0.0:8233/
Hit Ctrl-C to quit.

shows, click the first url in output which looks like: https://xxxxxxxxxxxxxxxxxxxxx-8233-colab.googleusercontent.com/index.html than that’s it.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:6
  • Comments:7

github_iconTop GitHub Comments

1reaction
SylveonBottlecommented, Oct 4, 2020

How does this compare to just running the orriginal on your own machine, in terms of performance / time required to color?

0reactions
basemdabbourcommented, May 10, 2022

Hello, can someone share google Colab for Style2Paints V4.5?.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Google Colab - A Step-by-step Guide - AlgoTrading101 Blog
All you have to do in Google Colab to enable a GPU or TPU is head over to the “Runtime” section, select “Change...
Read more >
Getting Started with Google CoLab | How to use Google Colab
In this video, we'll be discussing about the Google CoLab. Google Colab is a free cloud service and now it supports free GPU!...
Read more >
How to Use Google Colab for Deep Learning
NOTE: By default, the Colab notebook uses Python shell. To run terminal commands in Colab, you will have to use “!” at the...
Read more >
Quick Guide to Run your Python Scripts on Google Colaboratory
Accessing Files on Google Drive. Use the following script: from google.colab import drive drive.mount('/content/gdrive').
Read more >
Google Colab — Beginner's Walkthrough | Analytics Vidhya
4. Next, we will select a runtime type to use in our Kernel. In order to select a runtime, click on the “Runtime”...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found