analitics

Pages

Showing posts with label tutorial. Show all posts
Showing posts with label tutorial. Show all posts

Monday, November 27, 2023

Python 3.10.12 : My colab get images from imdb.com by the name - part 040.

Transformers provides thousands of pretrained models to perform tasks on different modalities such as text, vision, and audio.
You find more on my Colab Github repo.

Python 3.13.0a1 : How to use PyOTP for Microsoft Authenticator.

PyOTP is a Python library for generating and verifying one-time passwords. It can be used to implement two-factor (2FA) or multi-factor (MFA) authentication methods in web applications and in other systems that require users to log in.
Read more on this official webpage.
Install with pip tool and use this source code:
import pyotp

# Generare secret pentru utilizator
secret = pyotp.random_base32()

# Generare URL pentru codul QR
uri = pyotp.totp.TOTP(secret).provisioning_uri(name="UtilizatorExemplu", issuer_name="NumeServer")

# Exemplu de folosire a URI-ului într-o aplicație web sau pentru a genera un cod QR
print("Scanati urmatorul QR code in aplicatia Microsoft Authenticator:")
print(uri)
I run the python script:
python test_001.py
Scanati urmatorul QR code in aplicatia Microsoft Authenticator:
otpauth://totp/NumeServer:UtilizatorExemplu?secret=SPZICPQHAMWOIYCAZEHXZTPQDXEXZSWL&issuer=NumeServer
I used the uri output with one online tool to generate this QR image code and I tested with the aplication.
The account is added with NumeServer and UtilizatorExemplu.

Python 3.10.12 : My colab get images from imdb.com by the name - part 039.

You can use gspread and google-auth to get data from a spreadsheet from google drive and use it.
The colab notebook can be found on my colab repo on Github.
from google.colab import auth
auth.authenticate_user()

import gspread
from google.auth import default
creds, _ = default()

gc = gspread.authorize(creds)

# Open the spreadsheet by name
spreadsheet = gc.open('fiecare_saptamana')

# Choose a worksheet from the spreadsheet
worksheet = spreadsheet.get_worksheet(0)  # 0 represents the index of the first worksheet

# Get and print the data
data = worksheet.get_all_values()

#uncoment this line to print data sau add more source code to parse data
#print(data)

#the result will be 
#[['noreply@projects.blender.org', '437', 'notifications@github.com',  ...

Thursday, November 16, 2023

Python processing LiDAR data with Ouster SDK.

Lidar sensors for high-resolution, long range use in autonomous vehicles, robotics, mapping. Low-cost & reliable for any use case. Shipping today. See more on the official website.
You can download sample LiDAR data and test and use the Ouster Python SDK from the Ouster website.
The documentation for this python package can be found on this website.
See a simple demo on this youtube video named: 0 to SLAM in 60 Seconds.

Monday, November 13, 2023

PyScript - online tool .

PyScript is a platform for Python in the browser.
PyScript brings together two of the most vibrant technical ecosystems on the planet. If the web and Python had a baby, you'd get PyScript.
PyScript works because modern browsers support WebAssembly (abbreviated to WASM) - an instruction set for a virtual machine with an open specification and near native performance. PyScript takes versions of the Python interpreter compiled to WASM, and makes them easy to use inside the browser.
You can read more on the official webpage.
You can see my project tested with source code from a basic GitHub example.

Sunday, November 12, 2023

Python 3.13.0a1 : Testing basic instalation.

Today I tested a prerelease version of Python which is version python-3.13.0a1-amd64, the maintenance status is prerelease, the first release was 2024-10-01, the end of support is 2029-10, and the release schedule is PEP 719.
I got this version of python from the official python page.
The checksum for the downloaded file is from the same page and I checked with the WinMD5Free tool.
WinMD5Free is a tiny and fast utility to compute MD5 hash value for files. It works with Microsoft Windows 98, 2000, XP, Vista, and Windows 7/8/10/11.
The installation is simple, theoretically you don't have to make changes, you can only select a custom folder.
Open a command line and type the python command to see the installed version.
python
Python 3.13.0a1 (tags/v3.13.0a1:ad056f0, Oct 13 2023, 09:51:17) [MSC v.1935 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
In the command line opened by python with >>>, I tested the old specific commands:
>>> help()

Welcome to Python 3.13's help utility!

If this is your first time using Python, you should definitely check out
the tutorial on the internet at https://docs.python.org/3.13/tutorial/.

Enter the name of any module, keyword, or topic to get help on writing
Python programs and using Python modules.  To quit this help utility and
return to the interpreter, just type "quit".

To get a list of available modules, keywords, symbols, or topics, type
"modules", "keywords", "symbols", or "topics".  Each module also comes
with a one-line summary of what it does; to list the modules whose name
or summary contain a given string such as "spam", type "modules spam".

help> modules

Please wait a moment while I gather a list of all available modules...

test_sqlite3: testing with SQLite version 3.43.1
__future__          _testcapi           fractions           runpy
__hello__           _testclinic         ftplib              sched
__phello__          _testclinic_limited functools           secrets
_abc                _testconsole        gc                  select
_aix_support        _testimportmultiple genericpath         selectors
_ast                _testinternalcapi   getopt              shelve
_asyncio            _testmultiphase     getpass             shlex
_bisect             _testsinglephase    gettext             shutil
_blake2             _thread             glob                signal
_bz2                _threading_local    graphlib            site
_codecs             _tkinter            gzip                smtplib
_codecs_cn          _tokenize           hashlib             socket
_codecs_hk          _tracemalloc        heapq               socketserver
_codecs_iso2022     _typing             hmac                sqlite3
_codecs_jp          _uuid               html                sre_compile
_codecs_kr          _warnings           http                sre_constants
_codecs_tw          _weakref            idlelib             sre_parse
_collections        _weakrefset         imaplib             ssl
_collections_abc    _winapi             importlib           stat
_compat_pickle      _wmi                inspect             statistics
_compression        _xxinterpchannels   io                  string
_contextvars        _xxsubinterpreters  ipaddress           stringprep
_csv                _zoneinfo           itertools           struct
_ctypes             abc                 json                subprocess
_ctypes_test        antigravity         keyword             symtable
_datetime           argparse            linecache           sys
_decimal            array               locale              sysconfig
_elementtree        ast                 logging             tabnanny
_functools          asyncio             lzma                tarfile
_hashlib            atexit              mailbox             tempfile
_heapq              base64              marshal             test
_imp                bdb                 math                textwrap
_io                 binascii            mimetypes           this
_json               bisect              mmap                threading
_locale             builtins            modulefinder        time
_lsprof             bz2                 msvcrt              timeit
_lzma               cProfile            multiprocessing     tkinter
_markupbase         calendar            netrc               token
_md5                cmath               nt                  tokenize
_multibytecodec     cmd                 ntpath              tomllib
_multiprocessing    code                nturl2path          trace
_opcode             codecs              numbers             traceback
_opcode_metadata    codeop              opcode              tracemalloc
_operator           collections         operator            tty
_osx_support        colorsys            optparse            turtle
_overlapped         compileall          os                  turtledemo
_pickle             concurrent          pathlib             types
_py_abc             configparser        pdb                 typing
_pydatetime         contextlib          pickle              unicodedata
_pydecimal          contextvars         pickletools         unittest
_pyio               copy                pip                 urllib
_pylong             copyreg             pkgutil             uuid
_queue              csv                 platform            venv
_random             ctypes              plistlib            warnings
_sha1               curses              poplib              wave
_sha2               dataclasses         posixpath           weakref
_sha3               datetime            pprint              webbrowser
_signal             dbm                 profile             winreg
_sitebuiltins       decimal             pstats              winsound
_socket             difflib             pty                 wsgiref
_sqlite3            dis                 py_compile          xml
_sre                doctest             pyclbr              xmlrpc
_ssl                email               pydoc               xxsubtype
_stat               encodings           pydoc_data          zipapp
_statistics         ensurepip           pyexpat             zipfile
_string             enum                queue               zipimport
_strptime           errno               quopri              zlib
_struct             faulthandler        random              zoneinfo
_symtable           filecmp             re
_sysconfig          fileinput           reprlib
_testbuffer         fnmatch             rlcompleter

Enter any module name to get more help.  Or, type "modules spam" to search
for modules whose name or summary contain the string "spam".
help> ^Z
>>>
I tried to use quit and exit to return to the interactive Python shell but these not work. I need to use Ctr +Z.
Just for testing, I installed some Python modules, my recommendation is to use a virtualenv for each project.
For update I used:
python.exe -m pip install --upgrade pip

Python 3.8.12 : Django with replit online tool - part 001.

Now with the replit online tool it is easy to test projects in Django. You must set a variable SECRET_KEY in settings.py and press the Run button. This will open the web page with your project.
In the command line area you can use python to generate this variable, see the source code:
~/Django001$ python
Python 3.8.12 (default, Aug 30 2021, 16:42:10) 
[GCC 10.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import secrets
>>> secrets.token_urlsafe(32)
'yIXPv6u4uCt4AUWlkU4NCuoyJiZlLx5IFm8kG6h8RtA'
This is result of these first steps:
Use this command to create a website named catafest001:
~/Django001$ python manage.py startapp catafest001
Add this website to settings.py from django_project:
INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'catafest001',
]
Use this command to create an user with a password:
~/Django001$ python manage.py createsuperuser
Username (leave blank to use 'runner'): 
Email address: catafest@yahoo.com
Password: 
Password (again): 
The password is too similar to the username.
Bypass password validation and create user anyway? [y/N]: y
Superuser created successfully.
You can see I let the username runner and the password I set to adminadmin.
Into web area I set the URL to /admin and I use the username and the password to login into admin area.
NOTE: Although I did the correct steps for a simple project in django with admin page, it won't let me login as admin ... maybe the replit online tool needs some other changes or the cause is different ...

Monday, October 23, 2023

Python 3.10.12 : My colab get images from imdb.com by the name - part 038.

This colab notebook named catafest_050.ipynb will let you to get images from imdb.com by the name of the actor/actress.
You can find this notebook on my GitHub project.

Friday, October 20, 2023

Python 3.12.0 : Plyer example 001.

Plyer is a platform-independent api to use features commonly found on various platforms, notably mobile ones, in Python.
The project can be found on this GitHub project.
import time
from plyer import notification

if __name__ == "__main__":
	while True:
		notification.notify(title="Test",message="Text message",timeout=10)
		time.sleep(3000)
Let's see the most simple example with this python module.

Wednesday, October 18, 2023

Python 3.12.0 : PyAutoGUI example.

PyAutoGUI lets your Python scripts control the mouse and keyboard to automate interactions with other applications.
Make sure the modal dialog window is active and the desired text is visible before running the script.
This script waits for the user to activate the modal dialog window (for example, by clicking on the dialog window) and then moves the cursor to the coordinates of the label in the dialog window.
Copies the selected text to the clipboard using the classic Ctr and C keys.
Let's see the source code that does this.
import pyautogui
import time

# Display a short notification to prompt the user to activate the modal dialog window
print("Please activate the modal dialog window.")

# Wait for the user to activate the modal dialog window (you can click in the dialog window)
time.sleep(10) # Wait 10 seconds or enough time to activate the window

# Get the coordinates where you want to read the text on the label
x_label = 200 # Replace with the correct x coordinates
y_label = 300 # Replace with the correct y coordinates

# Move the mouse cursor to the coordinates of the label
pyautogui.moveTo(x_label, y_label)

# Select the text in the label using the mouse
pyautogui.dragTo(x_label + 200, y_label, duration=1) # Substitute the appropriate coordinates and duration

# Copies the selected text to the clipboard
pyautogui.hotkey("ctrl", "c")

# You can use the clipboard to access the read text
import clipboard
text_copied = clipboard.paste()

Saturday, September 9, 2023

News : Python 3.12.0 release candidate 2 now available.

This new release comes with many improvements for developers.
Here are some of them.
Modules from the standard library are now potentially suggested as part of the error messages displayed by the interpreter ...
NameError: name 'sys' is not defined. Did you forget to import 'sys'?
  • Many large and small performance improvements like - PEP 709;
  • Support for the Linux perf profiler to report Python function names in traces;
  • New type annotation syntax for generic classes - PEP 695;
  • More flexible f-string parsing, allowing many things previously disallowed - PEP 701;
  • Support for the buffer protocol in Python code - PEP 688;
  • A new debugging/profiling API - PEP 669;
  • Support for isolated sub interpreters with separate Global Interpreter Locks - PEP 684;
All PEPs can be found on this GitHub project.

Saturday, September 2, 2023

Python 3.11.4 : Issues in Fedora with PyGobject and sway-tests

Today I wanted to test this repo named sway-tests.
I followed the steps there and received an error from gi.repository.
This error is related to another issue related to PyGobject.
In Fedora Linux distro, installing PyGobject is done with pip like this:
$ pip install PyGobject
In order to have no errors, the dnf or dnf5 tool should be used like this ...
I tested the functionality of this installation with a simple example:
import gi

gi.require_version("Gtk", "3.0")
from gi.repository import Gtk

win = Gtk.Window()
win.connect("destroy", Gtk.main_quit)
win.show_all()
Gtk.main()
It worked very well.
After solving this issue, I returned to the initial one and tested the sway-tests.
$ whereis sway
$ env/bin/pytest --sway=/usr/bin/sway
$ sudo env/bin/pytest --sway=/usr/bin/sway
I used the command both with and without sudo.
Both generated the same errors.
For the following command I had to install ... xorg-x11-server-Xephyr:
Xephyr is an X server which has been implemented as an ordinary X application. It runs in a window just like other X applications, but it is an X server ...
... the fixed centered black window specific to the xorg runtime appeared and somewhere on the side the terminal showed me a bunch of errors.
... obviously, I don't know how well sway-tests is implemented, now it's an archived repo, but I solved the use of PyGobject in python on the Fedora linux distribution.

Friday, September 1, 2023

Python 3.11.0 : Use python to set your R application on shinyapps.io.

If you use the R programming language and shinyapps.io then you can use Python to set up your application.
I create my folder and I install the rsconnect-python python package.
mkdir rsconnect-python-001
cd rsconnect-python-001
pip install rsconnect-python --user
Collecting rsconnect-python
From the shinyapps webpage, I got my token and my secret for my account and I used this command:
rsconnect add --account catafest --name catafest --token YOUR_TOKEN --secret YOUR_SECRET
Detected the following inputs:
    name: COMMANDLINE
    insecure: DEFAULT
    account: COMMANDLINE
    token: COMMANDLINE
    secret: COMMANDLINE
Checking shinyapps.io credential...              [OK]
Added shinyapps.io credential "catafest".
You can see is set and working.
I used a simple R source code named app.r:
library(shiny)

# Definirea interfeței utilizatorului
ui <- fluidPage(
  titlePanel("Aplicație Shiny Simplă"),
  sidebarLayout(
    sidebarPanel(
      numericInput("num", "Introduceți un număr:", value = 1),
      actionButton("goButton", "Generează")
    ),
    mainPanel(
      textOutput("rezultat")
    )
  )
)

# Definirea serverului
server <- function(input, output) {
  observeEvent(input$goButton, {
    num <- input$num
    output$rezultat <- renderText({
      paste("Numărul introdus este:", num)
    })
  })
}

# Crearea aplicației Shiny
shinyApp(ui, server)
The app.py file has this source code:
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output

# Creați o aplicație Dash
app = dash.Dash(__name__)

# Definiți aspectul și structura aplicației
app.layout = html.Div([
    html.H1("Aplicație Dash Simplă"),
    dcc.Graph(id='grafic'),
    dcc.Input(id='input-numar', type='number', value=1),
    html.Div(id='rezultat')
])

# Definiți funcția callback pentru actualizarea graficului
@app.callback(
    Output('grafic', 'figure'),
    Input('input-numar', 'value')
)
def actualizare_grafic(numar):
    # Implementați logica de actualizare a graficului aici
    # Exemplu simplu: Un grafic cu o linie dreaptă cu panta egală cu numărul introdus
    import plotly.express as px
    import pandas as pd
    
    data = pd.DataFrame({'x': range(10), 'y': [numar * x for x in range(10)]})
    
    fig = px.line(data, x='x', y='y', title='Graficul personalizat')
    
    return fig

# Rulează aplicația
if __name__ == '__main__':
    app.run_server(debug=True)
I run this command into the RGUI command :
shiny::runApp("C:/PythonProjects/rsconnect-python-001/")

Listening on http://127.0.0.1:7036
The result on browser is this:
I used this command to deploy the application on shinyapps.io:
>rsconnect deploy shiny . --name catafest --title test
[WARNING] 2023-09-01T22:28:10+0300 Can't determine entrypoint; defaulting to 'app'
    Warning: Capturing the environment using 'pip freeze'.
             Consider creating a requirements.txt file instead.
...
Task done: Stopping old instances
Application successfully deployed to https://catafest.shinyapps.io/test/
...
  deploying - Starting instances
Task done: Stopping old instances
Application successfully deployed to https://catafest.shinyapps.io/rsconnect-python-001/
←[32;20m        [OK]
←[0m←[0mSaving deployed information...←[0m←[32;20m      [OK]
←[0m
The result can be found on the shinyapps.io - admin.
I need to fix this error, but first test without app.py was deploy on web.
[notice] A new release of pip is available: 23.1.2 -> 23.2.1
[notice] To update, run: /srv/connect/venv/bin/python3 -m pip install --upgrade pip
[2023-09-01T22:43:31.378864990+0000] Copying file manifest.json
←[31;20m        [ERROR]: Application deployment failed with error: Unhandled Exception: Child Task 1332185768 error: 
Unhandled Exception: 599
←[0mError: Application deployment failed with error: Unhandled Exception: Child Task 1332185768 error: 
Unhandled Exception: 599
I will come with better results.

Wednesday, August 23, 2023

Python 3.11.0 : Testing PE executable files x64 with capstone and pefile python modules.

You need to install the capstone python module.
pip install capstone --user
Collecting capstone
  Obtaining dependency information for capstone from https://files.pythonhosted.org/packages/d0/dd/b28df50316ca193
  
  dd1275a4c47115a720796d
  
  9e1501c1888c4bfa5dc2260/capstone-5.0.1-py3-none-win_amd64.whl.metadata
  
  Downloading capstone-5.0.1-py3-none-win_amd64.whl.metadata (3.5 kB)
Downloading capstone-5.0.1-py3-none-win_amd64.whl (1.3 MB)
   ---------------------------------------- 1.3/1.3 MB 1.6 MB/s eta 0:00:00
Installing collected packages: capstone
Successfully installed capstone-5.0.1
You need to install the pefile.
pip install pefile --user
Collecting pefile
  Downloading pefile-2023.2.7-py3-none-any.whl (71 kB)
     ---------------------------------------- 71.8/71.8 kB 564.7 kB/s eta 0:00:00
Installing collected packages: pefile
Successfully installed pefile-2023.2.7
I used an old simple PE64 executable create with fasm tool from this source code:
format PE64 GUI 5.0
entry start
include 'INCLUDE\win64a.inc'
section '.text' code readable executable
  start:
        push    rbp
        invoke  GetModuleHandle,0
        invoke  DialogBoxParam,rax,37,HWND_DESKTOP,DialogProc,0
        invoke  ExitProcess,0
proc DialogProc uses rbx rsi rdi,hWnd,wMsg,wParam,lParam
        mov             [hWnd],rcx
        mov             [wMsg],rdx
        mov             [wParam],r8
        mov             [lParam],r9

        cmp     [wMsg],WM_COMMAND
        je      wmcommand
        cmp     [wMsg],WM_CLOSE
        je      wmclose
        cmp     [wMsg],WM_SYSCOMMAND
        je      wmsyscommand
        xor     rax,rax
        jmp     finish
wmsyscommand:
        cmp     [wParam],SC_RESTORE
        je      sc_restore
        invoke  DefWindowProc,[hWnd],[wMsg],[wParam],[lParam]
        ret
   sc_restore:
        invoke  AnimateWindow,[hWnd],DWORD 1000,0x00040004      ;HERE IT IS
        invoke  ShowWindow,[hWnd],SW_RESTORE
        mov     rax,1
        ret
wmcommand:
        cmp     [wParam],BN_CLICKED shl 16 + IDOK
        jne     processed
        invoke  ShowWindow,[hWnd],SW_MINIMIZE
        ret
wmclose:
        invoke  EndDialog,[hWnd],0
processed:
        mov     rax,1
        ret ; this no need and use cmp to get error
;        cmp rax,0
;        je show_error
;        show_error:
;        invoke  GetLastError ;must call this first and save the result before doing anything else
;        invoke  wsprintf,...
;        invoke  MessageBox,...
finish:
        ret
endp
section '.idata' import data readable writeable
  library kernel,'KERNEL32.DLL',\
          user,'USER32.DLL'
  import kernel,\
         GetModuleHandle,'GetModuleHandleA',\
         ExitProcess,'ExitProcess'
  import user,\
         DialogBoxParam,'DialogBoxParamA',\
         CheckRadioButton,'CheckRadioButton',\
         GetDlgItemText,'GetDlgItemTextA',\
         IsDlgButtonChecked,'IsDlgButtonChecked',\
         MessageBox,'MessageBoxA',\
         DefWindowProc,'DefWindowProcA',\
         EndDialog,'EndDialog',\
         AnimateWindow,'AnimateWindow',\
         ShowWindow,'ShowWindow'
section '.rsrc' resource data readable
  directory RT_DIALOG,dialogs
  resource dialogs,\
           37,LANG_ENGLISH+SUBLANG_DEFAULT,demonstration
  dialog demonstration,'Create message box',70,70,190,175,WS_CAPTION+WS_POPUP+WS_SYSMENU+DS_MODALFRAME
       dialogitem 'BUTTON','OK',IDOK,85,150,45,15,WS_VISIBLE+WS_TABSTOP+BS_DEFPUSHBUTTON
  enddialog
This is the source code for python script:
import pefile
from capstone import *

exe_file = 'test_001_no_err_imp.EXE'
pe = pefile.PE(exe_file)

# find text section
offset = False
for section in pe.sections:
    if section.Name == b'.text\x00\x00\x00':
        offset = section.VirtualAddress
        codePtr = section.PointerToRawData
        codeEndPtr = codePtr+section.SizeOfRawData
        break

code = pe.get_memory_mapped_image()[codePtr:codeEndPtr]

# start disassembling text section
md = Cs(CS_ARCH_X86, CS_MODE_32)
md.detail = True
if offset:
    for i in md.disasm(code, offset):
        print('0x%x:\t%s\t%s' % (i.address, i.mnemonic, i.op_str))
This is the result:
python capstone_test_001.py
0x1000: push    ebp
0x1001: dec     eax
0x1002: sub     esp, 0x20
0x1005: dec     eax
0x1006: mov     ecx, 0
0x100c: call    dword ptr [0x105e]
0x1012: dec     eax
0x1013: add     esp, 0x20
0x1016: dec     eax
0x1017: sub     esp, 0x30
0x101a: dec     eax
0x101b: mov     ecx, eax
0x101d: dec     eax
0x101e: mov     edx, 0x25
0x1024: dec     ecx
0x1025: mov     eax, 0
0x102b: dec     ecx
0x102c: mov     ecx, 0x40105a
0x1032: dec     eax
0x1033: mov     dword ptr [esp + 0x20], 0
0x103b: call    dword ptr [0x109f]
0x1041: dec     eax
0x1042: add     esp, 0x30
0x1045: dec     eax
0x1046: sub     esp, 0x20
0x1049: dec     eax
0x104a: mov     ecx, 0
0x1050: call    dword ptr [0x1022]
0x1056: dec     eax
0x1057: add     esp, 0x20
0x105a: push    ebp
0x105b: dec     eax
0x105c: mov     ebp, esp
0x105e: dec     eax
0x105f: sub     esp, 8
0x1062: push    ebx
0x1063: push    esi
0x1064: push    edi
0x1065: dec     eax
0x1066: mov     dword ptr [ebp + 0x10], ecx
0x1069: dec     eax
0x106a: mov     dword ptr [ebp + 0x18], edx
0x106d: dec     esp
0x106e: mov     dword ptr [ebp + 0x20], eax
0x1071: dec     esp
0x1072: mov     dword ptr [ebp + 0x28], ecx
0x1075: dec     eax
0x1076: cmp     dword ptr [ebp + 0x18], 0x111
0x107d: je      0x1110
0x1083: dec     eax
0x1084: cmp     dword ptr [ebp + 0x18], 0x10
0x1088: je      0x1135
0x108e: dec     eax
0x108f: cmp     dword ptr [ebp + 0x18], 0x112
0x1096: je      0x10a0
0x1098: dec     eax
0x1099: xor     eax, eax
0x109b: jmp     0x115a
0x10a0: dec     eax
0x10a1: cmp     dword ptr [ebp + 0x20], 0xf120
0x10a8: je      0x10cd
0x10aa: dec     eax
0x10ab: sub     esp, 0x20
0x10ae: dec     eax
0x10af: mov     ecx, dword ptr [ebp + 0x10]
0x10b2: dec     eax
0x10b3: mov     edx, dword ptr [ebp + 0x18]
0x10b6: dec     esp
0x10b7: mov     eax, dword ptr [ebp + 0x20]
0x10ba: dec     esp
0x10bb: mov     ecx, dword ptr [ebp + 0x28]
0x10be: call    dword ptr [0x1024]
0x10c4: dec     eax
0x10c5: add     esp, 0x20
0x10c8: pop     edi
0x10c9: pop     esi
0x10ca: pop     ebx
0x10cb: leave
0x10cc: ret
0x10cd: dec     eax
0x10ce: sub     esp, 0x20
0x10d1: dec     eax
0x10d2: mov     ecx, dword ptr [ebp + 0x10]
0x10d5: mov     edx, 0x3e8
0x10da: dec     ecx
0x10db: mov     eax, 0x40004
0x10e1: call    dword ptr [0x1011]
0x10e7: dec     eax
0x10e8: add     esp, 0x20
0x10eb: dec     eax
0x10ec: sub     esp, 0x20
0x10ef: dec     eax
0x10f0: mov     ecx, dword ptr [ebp + 0x10]
0x10f3: dec     eax
0x10f4: mov     edx, 9
0x10fa: call    dword ptr [0x1000]
0x1100: dec     eax
0x1101: add     esp, 0x20
0x1104: dec     eax
0x1105: mov     eax, 1
0x110b: pop     edi
0x110c: pop     esi
0x110d: pop     ebx
0x110e: leave
0x110f: ret
0x1110: dec     eax
0x1111: cmp     dword ptr [ebp + 0x20], 1
0x1115: jne     0x114e
0x1117: dec     eax
0x1118: sub     esp, 0x20
0x111b: dec     eax
0x111c: mov     ecx, dword ptr [ebp + 0x10]
0x111f: dec     eax
0x1120: mov     edx, 6
0x1126: call    dword ptr [0xfd4]
0x112c: dec     eax
0x112d: add     esp, 0x20
0x1130: pop     edi
0x1131: pop     esi
0x1132: pop     ebx
0x1133: leave
0x1134: ret
0x1135: dec     eax
0x1136: sub     esp, 0x20
0x1139: dec     eax
0x113a: mov     ecx, dword ptr [ebp + 0x10]
0x113d: dec     eax
0x113e: mov     edx, 0
0x1144: call    dword ptr [0xfa6]
0x114a: dec     eax
0x114b: add     esp, 0x20
0x114e: dec     eax
0x114f: mov     eax, 1
0x1155: pop     edi
0x1156: pop     esi
0x1157: pop     ebx
0x1158: leave
0x1159: ret
0x115a: pop     edi
0x115b: pop     esi
0x115c: pop     ebx
0x115d: leave
0x115e: ret
0x115f: add     byte ptr [eax], al
0x1161: add     byte ptr [eax], al
0x1163: add     byte ptr [eax], al
0x1165: add     byte ptr [eax], al
0x1167: add     byte ptr [eax], al
0x1169: add     byte ptr [eax], al
0x116b: add     byte ptr [eax], al
0x116d: add     byte ptr [eax], al
0x116f: add     byte ptr [eax], al
0x1171: add     byte ptr [eax], al
0x1173: add     byte ptr [eax], al
0x1175: add     byte ptr [eax], al
0x1177: add     byte ptr [eax], al
0x1179: add     byte ptr [eax], al
0x117b: add     byte ptr [eax], al
0x117d: add     byte ptr [eax], al
0x117f: add     byte ptr [eax], al
0x1181: add     byte ptr [eax], al
0x1183: add     byte ptr [eax], al
0x1185: add     byte ptr [eax], al
0x1187: add     byte ptr [eax], al
0x1189: add     byte ptr [eax], al
0x118b: add     byte ptr [eax], al
0x118d: add     byte ptr [eax], al
0x118f: add     byte ptr [eax], al
0x1191: add     byte ptr [eax], al
0x1193: add     byte ptr [eax], al
0x1195: add     byte ptr [eax], al
0x1197: add     byte ptr [eax], al
0x1199: add     byte ptr [eax], al
0x119b: add     byte ptr [eax], al
0x119d: add     byte ptr [eax], al
0x119f: add     byte ptr [eax], al
0x11a1: add     byte ptr [eax], al
0x11a3: add     byte ptr [eax], al
0x11a5: add     byte ptr [eax], al
0x11a7: add     byte ptr [eax], al
0x11a9: add     byte ptr [eax], al
0x11ab: add     byte ptr [eax], al
0x11ad: add     byte ptr [eax], al
0x11af: add     byte ptr [eax], al
0x11b1: add     byte ptr [eax], al
0x11b3: add     byte ptr [eax], al
0x11b5: add     byte ptr [eax], al
0x11b7: add     byte ptr [eax], al
0x11b9: add     byte ptr [eax], al
0x11bb: add     byte ptr [eax], al
0x11bd: add     byte ptr [eax], al
0x11bf: add     byte ptr [eax], al
0x11c1: add     byte ptr [eax], al
0x11c3: add     byte ptr [eax], al
0x11c5: add     byte ptr [eax], al
0x11c7: add     byte ptr [eax], al
0x11c9: add     byte ptr [eax], al
0x11cb: add     byte ptr [eax], al
0x11cd: add     byte ptr [eax], al
0x11cf: add     byte ptr [eax], al
0x11d1: add     byte ptr [eax], al
0x11d3: add     byte ptr [eax], al
0x11d5: add     byte ptr [eax], al
0x11d7: add     byte ptr [eax], al
0x11d9: add     byte ptr [eax], al
0x11db: add     byte ptr [eax], al
0x11dd: add     byte ptr [eax], al
0x11df: add     byte ptr [eax], al
0x11e1: add     byte ptr [eax], al
0x11e3: add     byte ptr [eax], al
0x11e5: add     byte ptr [eax], al
0x11e7: add     byte ptr [eax], al
0x11e9: add     byte ptr [eax], al
0x11eb: add     byte ptr [eax], al
0x11ed: add     byte ptr [eax], al
0x11ef: add     byte ptr [eax], al
0x11f1: add     byte ptr [eax], al
0x11f3: add     byte ptr [eax], al
0x11f5: add     byte ptr [eax], al
0x11f7: add     byte ptr [eax], al
0x11f9: add     byte ptr [eax], al
0x11fb: add     byte ptr [eax], al
0x11fd: add     byte ptr [eax], al

Sunday, August 20, 2023

News : supervision python package.

We write your reusable computer vision tools. Whether you need to load your dataset from your hard drive, draw detections on an image or video, or count how many detections are in a zone. You can count on us!
I tested today with Fedora 39 Linux Distro using the GitHub project.
The installation from the source code worked with the following commands:
# clone repository and navigate to root directory
git clone https://github.com/roboflow/supervision.git
cd supervision

# setup python environment and activate it
python3 -m venv venv
source venv/bin/activate

# headless install
pip install -e "."

# desktop install
pip install -e ".[desktop]"
You can see more examples with this python package on this twitter account - skalskip92 !

Sunday, August 13, 2023

Python 3.10.12 : My colab test with Gated recurrent unit mechanism - part 037.

This is a simple example for Gated recurrent unit mechanism known as GRUs.
You can find this in my GitHub colab project.
import numpy as np
import tensorflow as tf
import keras
from keras import layers
units = 64
tf.keras.layers.GRU(
    units,
    activation="tanh",
    recurrent_activation="sigmoid",
    use_bias=True,
    kernel_initializer="glorot_uniform",
    recurrent_initializer="orthogonal",
    bias_initializer="zeros",
    kernel_regularizer=None,
    recurrent_regularizer=None,
    bias_regularizer=None,
    activity_regularizer=None,
    kernel_constraint=None,
    recurrent_constraint=None,
    bias_constraint=None,
    dropout=0.0,
    recurrent_dropout=0.0,
    return_sequences=False,
    return_state=False,
    go_backwards=False,
    stateful=False,
    unroll=False,
    time_major=False,
    reset_after=True,
)
inputs = tf.random.normal([32, 10, 8])
gru = tf.keras.layers.GRU(4)
output = gru(inputs)
print(output.shape)

gru = tf.keras.layers.GRU(4, return_sequences=True, return_state=True)
whole_sequence_output, final_state = gru(inputs)
print(whole_sequence_output.shape)
print(final_state.shape)

Saturday, August 12, 2023

Python 3.10.12 : My colab tutorials and news from colab - part 036.

Today I recapitulated a bit the artificial intelligence part and a simple example for google drive.
I created two notebooks in collaboration and added them to my github repo.
The most interesting is the one with textgenrnn.
textgenrnn is an modern neural network architecture which utilizes new techniques as attention-weighting and skip-embedding to accelerate training
The last notebook colab is catafest_045.

News : Colab behavior through runtime .

I would like Google to emphasize more on the development side some elements that work like robots by interfacing with the development side.
Today I worked a little on artificial intelligence and I realized that it doesn't create textgenrnn_weights.hdf5 file for training created with the Python textgenrnn mode.
A solution is to reset the runtime with Ctrl+M and resume running.
They specify RESTART RUNTIME when using Python modules, see:
WARNING: The following packages were previously imported in this runtime:
   [numpy]
You must restart the runtime in order to use newly installed versions.
In this case, with the creation of textgenrnn_weights.hdf5 file, it is more difficult to understand and cannot be seen easily.

Thursday, August 10, 2023

Python 3.10.12 : My colab tutorials and news from colab - part 035.

In this notebook I will show you how to use python to run a program written in the programming language for CUDA.
This allows you to use NVIDIA CUDA Compiler Driver NVCC, see this official webpage.
NVCC Plugin for Jupyter Notebook by https://github.com/andreinechaev/nvcc4jupyter.
The example I tested is simple:
# This is formatted as CUDA code
__global__ void cuda_hello(){
    printf("Hello World from GPU!\n");
}

int main() {
    cuda_hello<<<1,1>>>();
    return 0;
}

Tuesday, July 11, 2023

Python 3.8.10 : My colab tutorials and news from colab - part 034.

I add a new colab notebook with a simple source code to list all running VM processes from the colab notebook
You can see more examples on my GitHub colab google repo.
This is the source code:
%%sh
echo "List all running VM processes."
ps -ef
echo "Done"