Today, I update my GitHub repo with python source code tested on colab google.
You can see this notebook named catafest_032.ipynb on my GitHub repo.
Is a blog about python programming language. You can see my work with python programming language, tutorials and news.
pip install rembg
Collecting rembg
Downloading rembg-2.0.25-py3-none-any.whl (12 kB)
from rembg import remove
from PIL import Image
input_path = 'input001.png'
output_path = 'output001.png'
input = Image.open(input_path)
output = remove(input)
output.save(output_path)
python remove_background.py
Access denied with the following error:
Too many users have viewed or downloaded this file recently. Please
try accessing the file again later. If the file you are trying to
access is particularly large or is shared with many people, it may
take up to 24 hours to be able to view or download the file. If you
still can't access a file after 24 hours, contact your domain
administrator.
You may still be able to access the file from the browser:
https://drive.google.com/uc?id=1tCU5MM1LhRgGou5OpmpjBQbSrYIUoYab
...
C:\Users\your_user\.u2net\
from web3 import Web3
node_provider = "https://mainnet.infura.io/v3/1f2fb5d1e1be4c11acdbbb07a2e06a1c"
web3_connection = Web3(Web3.HTTPProvider(node_provider))
def is_connected():
print(web3_connection.isConnected())
def latest_block():
print(web3_connection.eth.block_number)
def balanceETH(ETH_address):
balance = web3_connection.eth.get_balance(ETH_address)
balance_for_ETH = web3_connection.fromWei(balance,'ether')
print(balance_for_ETH)
(web3_001) [mythcat@fedora PythonProjects]$ vi web3_func_001.py
(web3_001) [mythcat@fedora PythonProjects]$ python
Python 3.9.13 (main, Aug 25 2022, 23:26:10)
[GCC 11.2.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from web3_func_001 import *
>>> is_connected()
True
>>> latest_block()
15516253
>>> balanceETH("0x74E55f28a8A0158b466FcB481EC7e6bE45D1DB91")
0
import bpy
#get active object - default
obj = bpy.context.active_object
# set the default start for working with Geometry Nodes modifier
# you need to have a Geometry Nodes modifier
node_group = obj.modifiers['GeometryNodes'].node_group
nodes = node_group.nodes
#get the node named 'Group Output'
geom_out = nodes.get('Group Output')
#create a string node
string_node = nodes.new('FunctionNodeInputString')
# set the name to 'String'
string_out = string_node.outputs['String']
# set the value to "This is a string"
string_node.string = "This is a string"
# link to the Group Output
node_group.links.new(string_out, geom_out.inputs[-1])
winget install --id Python.Python.3 -e --source winget
Found Python 3 [Python.Python.3] Version 3.10.6
This application is licensed to you by its owner.
Microsoft is not responsible for, nor does it grant any licenses to, third-party packages.
Downloading https://www.python.org/ftp/python/3.10.6/python-3.10.6-amd64.exe
██████████████████████████████ 27.5 MB / 27.5 MB
Successfully verified installer hash
Starting package install...
Successfully installed
python.exe -m pip install manim
...
Successfully installed Pillow-9.2.0 Pygments-2.12.0 certifi-2022.6.15 charset-no
rmalizer-2.1.0 click-8.1.3 click-default-group-1.2.2 cloup-0.13.1 colour-0.1.5 c
ommonmark-0.9.1 decorator-5.1.1 glcontext-2.3.6 idna-3.3 isosurfaces-0.1.0 manim
-0.16.0.post0 manimpango-0.4.1 mapbox-earcut-0.12.11 moderngl-5.6.4 moderngl-win
dow-2.4.1 multipledispatch-0.6.0 networkx-2.8.5 pycairo-1.21.0 pydub-0.25.1 pygl
et-1.5.26 pyrr-0.10.3 requests-2.28.1 rich-12.5.1 scipy-1.9.0 screeninfo-0.8 ski
a-pathops-0.7.2 srt-3.5.2 tqdm-4.64.0 urllib3-1.26.11 watchdog-2.1.9
from manim import *
# a simple python class
class DefaultClassExample(Scene):
def construct(self):
# add a circle
circle = Circle()
# create a animation
self.play(Create(circle))
manim -pql manim_001.py test
Manim Community v0.16.0.post0
...
INFO Previewed File at: 'C:\Python310\media\videos\manim_001\480p15\DefaultClassExample.mp4'
...
# import python packages
import bpy
from mathutils import Vector
# create a simpple BezierCurve and rename it with 'BezierCurveGeormetryNode'
bpy.ops.curve.primitive_bezier_curve_add()
bpy.ops.object.modifier_add(type='NODES')
curve = bpy.context.active_object
curve.name = 'BezierCurveGeormetryNode'
# define a function for GroupInit and GroupOutput
def new_GeometryNodes_group():
''' Create a new empty node group that can be used
in a GeometryNodes modifier.
'''
node_group = bpy.data.node_groups.new('GeometryNodes', 'GeometryNodeTree')
inNode = node_group.nodes.new('NodeGroupInput')
inNode.outputs.new('NodeSocketGeometry', 'Geometry')
outNode = node_group.nodes.new('NodeGroupOutput')
outNode.inputs.new('NodeSocketGeometry', 'Geometry')
node_group.links.new(inNode.outputs['Geometry'], outNode.inputs['Geometry'])
# the -3.5 is value for how far will be set the GroupInit and GroupOutput in the area of GeormetryNodes
inNode.location = Vector((-3.5*inNode.width, 0))
outNode.location = Vector((3.5*outNode.width, 0))
return node_group
# the default curve modifier has no node group set, you need to set :
if curve.modifiers[-1].node_group:
node_group = curve.modifiers[-1].node_group
else:
node_group = new_GeometryNodes_group()
curve.modifiers[-1].node_group = node_group
# set default grup node as nodes
nodes = node_group.nodes
# get both nodes for each one
group_in = nodes.get('Group Input')
group_out = nodes.get('Group Output')
# add the GeometryNodeObjectInfo to the GeometryNode area
new_node_obj = nodes.new('GeometryNodeObjectInfo')
new_node_obj.inputs[0].default_value = bpy.data.objects["BezierCurveGeormetryNode"]
C:\Python310>python -m pip install --upgrade pip
Requirement already satisfied: pip in c:\python310\lib\site-packages (22.1)
Collecting pip
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, stat
us=None)) after connection broken by 'NewConnectionError(': Failed to establish a n
ew connection: [Errno 11001] getaddrinfo failed')': /packages/1f/2c/d9626f045e7b
49a6225c6b09257861f24da78f4e5f23af2ddbdf852c99b8/pip-22.2.2-py3-none-any.whl
Downloading pip-22.2.2-py3-none-any.whl (2.0 MB)
---------------------------------------- 2.0/2.0 MB 1.5 MB/s eta 0:00:00
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 22.1
Uninstalling pip-22.1:
Successfully uninstalled pip-22.1
Successfully installed pip-22.2.2
C:\Python310>python -m pip install lxml-4.9.0-cp310-cp310-win_amd64.whl
Processing c:\python310\lxml-4.9.0-cp310-cp310-win_amd64.whl
Installing collected packages: lxml
Successfully installed lxml-4.9.0
C:\Python310>python -m pip install EbookLib --user
Collecting EbookLib
Using cached EbookLib-0.17.1.tar.gz (111 kB)
Preparing metadata (setup.py) ... done
Requirement already satisfied: lxml in c:\python310\lib\site-packages (from Eboo
kLib) (4.9.0)
Collecting six
Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)
Using legacy 'setup.py install' for EbookLib, since package 'wheel' is not insta
lled.
Installing collected packages: six, EbookLib
Running setup.py install for EbookLib ... done
Successfully installed EbookLib-0.17.1 six-1.16.0
from ebooklib import epub
book = epub.EpubBook()
# set metadata
book.set_identifier('__1976')
book.set_title('')
book.set_language('en')
book.add_author('Autho: Cătălin George Feștilă')
# create chapter
cap001 = epub.EpubHtml(title='Intro', file_name='capitolul_01.xhtml', lang='ro')
cap001.content=u'<h1>Introducere</h1><p>Această carte este...</p>'
# add chapter
book.add_item(cap001)
# define Table Of Contents
book.toc = (epub.Link('capitolul_01.xhtml', 'Introducere', 'introducere'),
(epub.Section('O carte simplă'),
(cap001, ))
)
# add default NCX and Nav file
book.add_item(epub.EpubNcx())
book.add_item(epub.EpubNav())
# define CSS style
style = 'BODY {color: white;}'
nav_css = epub.EpubItem(uid="style_nav", file_name="style/nav.css", media_type="text/css", content=style)
# add CSS file
book.add_item(nav_css)
# basic spine
book.spine = ['nav', cap001]
# write to the file
epub.write_epub('ro_lan_test.epub', book, {})
C:\PythonProjects\ConvertImages>python -m pip install --upgrade pip
Requirement already satisfied: pip in c:\python311alpha\lib\site-packages (22.1.
2)
Collecting pip
Downloading pip-22.2-py3-none-any.whl (2.0 MB)
---------------------------------------- 2.0/2.0 MB 3.3 MB/s eta 0:00:00
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 22.1.2
Uninstalling pip-22.1.2:
Successfully uninstalled pip-22.1.2
Successfully installed pip-22.2
C:\PythonProjects\ConvertImages>python -m pip install --upgrade Pillow
Collecting Pillow
Downloading Pillow-9.2.0-cp311-cp311-win_amd64.whl (3.3 MB)
---------------------------------------- 3.3/3.3 MB 4.0 MB/s eta 0:00:00
Installing collected packages: Pillow
Successfully installed Pillow-9.2.0
from PIL import Image
# open the image file WEBP
image = Image.open('waterski2.webp')
# show the image
image.show()
# convert the image to RGB color
image = image.convert('RGB')
# save PNG RGB image
image.save('waterski2_RGB_PNG.png', 'png')
# save JPG RGB image
image.save('waterski2_RGB_JPG.jpg', 'jpeg')
# open the image file JPG
image_jpg = Image.open('waterski2_RGB_JPG.jpg')
# convert the image to RGB color
image_rgb_jpg = image_jpg.convert('RGB')
# save PNG RGB image from JPG
image_rgb_jpg.save('new-image_RGB_PNG_from_JPG.png', 'png')
#same process of conversion to WEBP file type
# from png image
image = Image.open('waterski2_RGB_PNG.png')
image = image.convert('RGB')
image.save('new-image_RGB_WEBP_from_png.webp', 'webp')
# from jpg image
image = Image.open('waterski2_RGB_JPG.jpg')
image = image.convert('RGB')
image.save('new-image_RGB_WEBP_from_jpg.webp', 'webp')
import bpy
def menu_func(self, context):
'''Open explorer in windows systems'''
self.layout.operator(
"wm.url_open", text="Open explorer", icon='FILE_FOLDER').url = "C:/"
def register():
bpy.types.TOPBAR_MT_help.append(menu_func)
def unregister():
bpy.types.TOPBAR_MT_help.remove(menu_func)
if __name__ == "__main__":
register()
import bpy
def menu_func(self, context):
self.layout.operator(
OpenOperator.bl_idname, text="Open explorer", icon='FILE_FOLDER')
class OpenOperator(bpy.types.Operator):
"""Open explorer in windows systems"""
bl_idname = "wm.open_explorer"
bl_label = "Open explorer"
def execute(self, context):
bpy.ops.wm.url_open(url="C:/")
return {'FINISHED'}
def register():
bpy.utils.register_class(OpenOperator)
bpy.types.TOPBAR_MT_help.append(menu_func)
def unregister():
bpy.utils.unregister_class(OpenOperator)
bpy.types.TOPBAR_MT_help.remove(menu_func)
if __name__ == "__main__":
register()
import pkg_resources
from subprocess import call
packages = [dist.project_name for dist in pkg_resources.working_set]
call("pip install --upgrade " + ' '.join(packages), shell=True)
C:\Python311alpha>python.exe update_python.py
...
Requirement already satisfied: pip-api in c:\python311alpha\lib\site-packages (0.0.29)
Requirement already satisfied: pypng in c:\python311alpha\lib\site-packages (0.0.21)
Requirement already satisfied: PyGetWindow in c:\python311alpha\lib\site-packages (0.0.9)
Requirement already satisfied: bs4 in c:\python311alpha\lib\site-packages (0.0.1)