Flask on Google Colab, A free web app server

Flask on Google Colab Colab is strong and famous by its support of GPU/TPU. However, with Flask, it can be a web app server. That’s very cool! Ngrok Expose the localhost to a public temporary url that can be shared with all around the world. That’s so cool! But how? Flask on Google Colab: https://medium.com/@kshitijvijay271199/flask-on-google-colab-f6525986797b Transform Google Colab to a GPU instance with full SSH access: https://imadelhanafi.com/posts/google_colal_server/ Flask Chatroom on Colab: https://colab.research.google.com/github/shanaka-desoysa/shanaka-desoysa.github.io/blob/source/content/flask/Flask_Chat_Colab.ipynb#scrollTo=Hmx5lVRRa2Hq about the no-token ngrok test: no-token ngrok: https://dl.equinox.io/ngrok/ngrok/stable 1 Download: wget https://bin.

READ MORE

手把手教你搭建一个GAN(生成对抗网络)模型

手把手教你搭建一个GAN(生成对抗网络)模型 这个教程用 Keras 实现一个简单的GAN (生成对抗网络)模型. 基于这个:mnistGAN项目,我们将用到Keras 这个python 库。 将用到的python packages: keras: 神经网络模型相关 matplotlib: 画图 tensorflow: keras运行基础 tqdm: 进度条 Talk is cheap, show me the code. 1. 导入包: import os import numpy as np import matplotlib.pyplot as plt from tqdm import tqdm from keras.layers import Input # input layer from keras.models import Model, Sequential from keras.layers.core import Dense, Dropout from keras.layers.advanced_activations import LeakyReLU from keras.datasets import mnist from keras.optimizers import Adam from keras import initializers 2. 定义几个变量: # Let Keras know that we are using tensorflow as our backend engine os.

READ MORE

[转]Python 解析 PDF 文本和表格的四大方法介绍

Python 解析 PDF 文本和表格的四大方法介绍 == code for paper and NSFC Proj. parsing==: https://gitee.com/sonica/pdf_parsing 看到一个不错的知识文章,和大家分享一下: 很多文件为了安全都会存成 PDF 格式,比如有的论文、技术文档、书籍等等,程序读取这些文档内容带来了很多麻烦。Python 目前解析 PDF 的扩展包有很多,这里将对比介绍 PyPDF2、pdfplumber、pdfminer3k 以及 Camelot,告诉你哪个是好用的 PDF 解析工具。 本文使用的案例 PDF 文档下载链接: 链接: https://pan.baidu.com/s/1zH7vY47AqBYKM0XbdABbUA 提取码:xhem 另外,获取 PDF 文档之后,会发现 PDF 文档中的换行符是以行的位置相同的,而不是跟段落相同。 1. PyPDF2 解析 PDF 文档 这里主要参考了 2019-03-07,Usman Malik 写的一篇文章: Python for NLP: Working with Text and PDF Files 使用 Python 安装 PyPDF2 扩展包: pip install PyPDF2 #---------OR conda install -c conda-forge pypdf2 读取 PDF 文件 import PyPDF2 path = r"****.pdf" #使用open的‘rb’方法打开pdf文件(这里必须得使用二进制rb的读取方式) mypdf = open(path,mode='rb') #调用PdfFileReader函数 pdf_document = PyPDF2.

READ MORE

Storage Location for Unpacked Chrome Extensions

Storage Location for Unpacked Extensions Extension engine does not explicitly change their location or add a reference to its local paths, they are left in the place where there are selected from in all Operating Systems. Ex: If i load a unpacked Extension from E:\Chrome Extension the unpacked Extension is still in the same location Storage Location for Packed Extensions Navigate to chrome://version/ and look for Profile Path, it is your default directory and Extensions Folder is where all the extensions, apps, themes are stored

READ MORE

node2vec 调节不同节点的pq值

要对不同节点配置不同的pq值,需要sampling_strategy这个参数配合。通过dict_my_strategy传入一个字典即可。 import networkx as nx import matplotlib.pyplot as plt from node2vec import Node2Vec G = nx.les_miserables_graph() # nx.draw_networkx(G, with_labels=True) # draw the graph, simplest way. # nx.draw_spring(G, with_labels = True) # plt.show() dict_my_strategy = {'Myriel':{'p':10, 'q':0.1}} # use this dict to regulate the p,q for specific nodes. print(' walking...') node2vec = Node2Vec(G, dimensions=16, walk_length=20, num_walks=10, p=1, q=1, workers=1, sampling_strategy=dict_my_strategy) # Embed nodes print(' training...') model = node2vec.fit(window=4, min_count=1)

READ MORE

TeamViewer的替代品:realVNC

TeamViewer的替代品:realVNC official web: realvnc: https://www.realvnc.com/ steps: 在需要被控制的PC上装上realVNC的服务软件(real VNC server)download 在控制端PC上装上realVNC的客户端(real VNC viewer) download 在 realvnc.com 网站上注册账户。 2个电脑的应用上都登入账户,并在服务端设置访问密码,即可远程控制。 ps: 免费的个人版没法互相传输文件,剪贴板里的text是可以分享的。 修复了TeamViewer上 mac 控制 remote 的Ctrl + / 无效的问题。 速度还可以,作为teamviewer的一个补充还是不错的。

READ MORE

Introduction of Generator in Python

Python中生成器的原理与使用详解 原创牛大财有大才 发布于2018-09-05 14:36:38 0.range() 函数,其功能是创建一个整数列表,一般用在 for 循环中 语法格式:range(start, stop, step),参数使用参考如下: *start: 计数从 start 开始。默认是从 0 开始。例如range(4)等价于range(0, 4);结果:(0,1,2,3)* *stop: 计数到 stop 结束,但不包括 stop。例如:range(0, 5) 是[0, 1, 2, 3, 4]没有5* step:步长,默认为1。例如:range(0, 5) 等价于 range(0, 5, 1) #使用range函数建立列表 ls =[x*2 for x in range(10)] print(ls)#[0, 2, 4, 6, 8, 10, 12, 14, 16, 18] ls1 = [x for x in range(0,10,2)] #步长是2. print(ls1) #[0, 2, 4, 6, 8] ls2 = [x for x in range(3,10,2)] #开始从3开始,步长是2. print(ls2) # [3, 5, 7, 9] ls3 =[x for x in range(0, -10, -1)] #负数的使用 print(ls3) #[0, -1, -2, -3, -4, -5, -6, -7, -8, -9] print(range(0)) #range(0, 0) print(range(1,0)) #range(1, 0) 1.

READ MORE

Excel: assign label to scatter chart using specific cell values

ref: https://www.get-digital-help.com/custom-data-labels-in-x-y-scatter-chart/ Improve your X Y Scatter Chart with custom data labels Author: Oscar Cronquist Article last updated on February 25, 2019 The picture above shows a chart that has custom data labels, they are linked to specific cell values. What’s on this page How to apply custom data labels in Excel 2013 and later versions How to add data label shapes How to rearrange data labels Video Download Excel file Workaround for earlier Excel versions Excel Macro - Apply custom data labels Where to copy the code How to use macro Download Excel file This means that you can build a dynamic chart and automatically change the labels depending on what is shown on the chart.

READ MORE

reverse/inverse a mapping but with multiple values for each key

reverse/inverse a mapping but with multiple values for each key multi mappping dictionary , reverse/inverse ''' mrg_dictionary: {15: {16, 19, 21, 23}, 22: {18}} inv_merging_led_dict: {16: 15, 19: 15, 21: 15, 23: 15, 18: 22} mrg_dictionary --> inv_merging_led_dict ''' mrg_dictionary = {15: {16, 19, 21, 23}, 22: {18}} inv_merging_led_dict = {value:key for key in mrg_dictionary for value in mrg_dictionary[key]} print(inv_merging_led_dict) ''' inv_merging_led_dict: {16: 15, 19: 15, 21: 15, 23: 15, 18: 22} mrg_dictionary: {15: {16, 19, 21, 23}, 22: {18}} inv_merging_led_dict --> mrg_dictionary ''' valueset = set(inv_merging_led_dict.

READ MORE