LittleDogAI, now integrated into the LittleDog package, is an advanced Python tool that simplifies coding by utilizing AI and natural language processing (NLP). It converts user instructions into executable Python code, supporting both text and image inputs via the Gemini API. This package is designed to automate and streamline the coding workflow for developers and data scientists, making complex tasks more accessible and less time-consuming.
AI-Powered Code Generation: Converts natural language instructions into executable Python scripts.
Text and Image Input Support: Handles both text commands and image data to generate relevant Python code.
Seamless Execution: Automatically executes the generated code within your environment.
Interactive Interface: Provides a user-friendly way to automate tasks, generate code snippets, and manage visual data.
Logging and Debugging: Logs operations and provides feedback on code generation, aiding in debugging and troubleshooting.
To install the LittleDogAI module, ensure you have the following dependencies installed:
pip install opencv-contrib-python numpy matplotlib google-generativeai
Ensure your Python version is 3.9 or higher.
Automating repetitive coding tasks.
Generating code snippets based on natural language instructions.
Processing and analyzing visual data through AI-generated scripts.
Simplifying the workflow for data scientists and developers.
show_dependencies(): This function displays the required dependencies for LittleDog to function correctly.
littledogai_lilfy(code, warnings=True, dependency_list=True): This is the primary function for generating Python code from text instructions.
code: This argument takes the user's instructions as a string.
warings: This boolean flag controls whether to display warnings about potential code variations. (default: True)
dependency_list: This boolean flag determines if the generated code includes instructions on installing dependencies. (default: True) The function interacts with Google Generative AI to create Python code based on the provided instructions. It then executes the generated code and displays the results (with warnings if enabled).
littledogai_lilfy_IMAGE(code, image_path, warings=True, dependency_list=True): This function is similar to littledogai_lilfy() but additionally accepts an image path for tasks involving image data.
image_path: This argument takes the path to the image file.
OpenCV Functions: LittleDog provides functions for various OpenCV operations, including:
Basic Functions:
img_read(image_path, window_name): Reads an image and displays it in a window.
vid_read(video_path, window_name): Reads a video and displays it frame-by-frame in a window.
img_rescale(image_path, scale, window_name): Rescales an image to a specified scale and displays it.
vid_rescale(video_path, scale, window_name): Rescales a video to a specified scale and displays it frame-by-frame.
Image Creation and Display:
blank_paint(color, color_range, window_name): Creates a blank image with a specified color within a defined region. Displays the image in a window.
draw_rectangle(color, outline, window_name): Draws a rectangle on a blank image with specified color, thickness, and displays it in a window.
draw_circle(color, outline, radius, window_name): Draws a circle on a blank image with specified color, thickness, radius, and displays it in a window.
draw_line(color, outline, window_name): Draws a line on a blank image with specified color, thickness, and displays it in a window.
write_text(text, color, outline, window_name): Writes text on a blank image with specified text content, color, thickness, and displays it in a window.
Image Modification:
img_modify_RGB2GREY(image_path, window_name): Converts an RGB image to grayscale and displays it in a window.
img_modify_EDGECASCADE_CANNY(image_path, window_name): Applies Canny edge detection to an image and displays the result.
img_modify_DIALATE(image_path, window_name): Applies dilation operation to an image (likely to enhance edges) and displays it.
img_modify_ERODE(image_path, window_name): Applies erosion operation to an image (likely to reduce noise) and displays it.
img_modify_SCALE_ENLARGE(image_path, window_name): Enlarges an image using cubic interpolation and displays it.
img_modify_SCALE_SHRINK(image_path, window_name): Shrinks an image using area interpolation and displays it.
img_find_CONTOURS(image_path, window_name): Finds contours in an image, displays the original image with contours, and prints the number of contours found.
Image Transformation:
image_modify_TRANSLATE(image_path, window_name): Shifts the image position horizontally by a specified value.
img_modify_FLIPv(image_path, window_name): Flips the image vertically and displays it.
img_modify_FLIPh(image_path, window_name): Flips the image horizontally and displays it.
img_modify_ROTATE(image_path, window_name): Rotates the image by a specified angle and displays it.
img_modify_CROP(image_path, window_name): Crops a rectangular region from the image and displays it.
img_modify_SHEAR_X(image_path, window_name): Shears the image in the X-axis and displays it.
img_modify_SHEAR_Y(image_path, window_name): Shears the image in the Y-axis and displays it.
Image Blurring:
img_modify_BLUR_2DKconv(image_path, window_name): Applies a 2D convolution blur to the image and displays it.
img_modify_BLUR_Avg(image_path, window_name): Applies average blurring to the image and displays it.
img_modify_BLUR_Gaus(image_path, window_name): Applies Gaussian blurring to the image and displays it.
img_modify_BLUR_Mead(image_path, window_name): Applies median blurring to the image and displays it.
img_modify_BLUR_Bilat(image_path, window_name): Applies bilateral blurring to the image and displays it.
Sure, here are the functions described in a single line, classified according to the task done:
Splitting color spaces:
img_split_COLORSPACES_RGB(image_path): Splits a color image into its individual Blue, Green, and Red channels.
Image modification:
img_modify_MASK_CIRCLE(image_path): Creates a circular mask and applies it to an image to achieve a masking effect.
img_modify_BLEND_ALPHABLEND(image1_path, image2_path): Performs alpha blending on two images to create a composite image.
Image Processing and Visualization:
img_show_PLOT_GRAPH_COLOR_HISTOGRAM(image_path): Calculates and displays the color histogram of an image.
Bitwise operations (pictorial representation not provided):
img_representated_BITWISE_AND(): Performs bitwise AND operation on two default images.
img_representated_BITWISE_OR(): Performs bitwise OR operation on two default images.
img_representated_BITWISE_XOR(): Performs bitwise XOR operation on two default images.
img_representated_BITWISE_NOT(): Performs bitwise NOT operation on two default images.
show_dependencies: show_dependencies()
Output:
opencv-contrib- numpy matplotlib google-generativeai
python>=3.9
littledogai_lilfy: littledogai_lilfy("a number x + a number z = number c. Display z")
Output:
WARNING: The code generated might not be the same every time...
(Generated code execution result)
littledogai_lilfy_IMAGE:littledogai_lilfy_IMAGE("a number x + a number z = number c. Display z", image_path="path_to_image.jpg")
Output:
WARNING: The code generated might not be the same every time...
(Generated code with image handling)
img_read: img_read("path_to_image.jpg")
Output:
Task has started
Press any key to cancel
(Displays the image)
Task has ended
vid_read: vid_read("path_to_video.mp4")
Output:
Task has started
Press 'x' key to cancel
(Plays the video)
Task has ended
img_rescale: img_rescale("path_to_image.jpg", scale=0.5)
Output:
Task has started
Press any key to cancel
(Displays the rescaled image)
Task has ended
vid_rescale:vid_rescale("path_to_video.mp4", scale=0.75)
Output:
Task has started
Press 'x' key to cancel
(Plays the rescaled video)
Task has ended
blank_paint:blank_paint(color=(255, 0, 0), color_range=(50, 150, 200, 300))
Output:
Task has started
Press any key to cancel
(Displays the painted image)
Task has ended
draw_rectangle: draw_rectangle(color=(0, 255, 0), outline=5)
Output:
Task has started
Press any key to cancel
(Displays the image with a rectangle)
Task has ended
draw_circle:draw_circle(color=(0, 0, 255), radius=50)
Output:
Task has started
Press any key to cancel
(Displays the image with a circle)
Task has ended
draw_line:draw_line(color=(255, 255, 255), outline=3)
Output:
Task has started
Press any key to cancel
(Displays the image with a line)
Task has ended
write_text:write_text(text="Hello, World!", color=(255, 255, 0))
Output:
Task has started
Press any key to cancel
(Displays the image with the text)
Task has ended
img_modify_RGB2GREY:img_modify_RGB2GREY("path_to_image.jpg")
Output:
Task has started
Press any key to cancel
(Displays the greyscale image)
Task has ended
img_modify_EDGECASCADE_CANNY:img_modify_EDGECASCADE_CANNY("path_to_image.jpg")
Output:
Task has started
Press any key to cancel
(Displays the canny edged image)
Task has ended
img_modify_DIALATE:img_modify_DIALATE("path_to_image.jpg")
Output:
Task has started
Press any key to cancel
(Displays the dialated image)
Task has ended
img_modify_ERODE('cat_img.jpg')
Output: Displays the eroded image in a window named 'Eroded Image'.
img_modify_SCALE_ENLARGE('lady_img.jpg')
Output: Displays the enlarged image in a window named 'Enlarged Image'.
img_modify_SCALE_SHRINK('lady_img.jpg')
Output: Displays the shrunk image in a window named 'Shrinked Image'.
img_find_CONTOURS('cat_img.jpg')
Output: Displays the image with contours drawn on it in a window named 'Contours'.
image_modify_TRANSLATE('lady_img.jpg')
Output: Displays the translated image in a window named 'Translated Image'.
img_modify_FLIPv('cat_img.jpg')
Output: Displays the vertically flipped image in a window named 'Vertically flipped Image'.
img_modify_FLIPh('cat_img.jpg')
Output: Displays the horizontally flipped image in a window named 'Horizontally flipped Image'.
img_modify_ROTATE('cat_img.jpg')
Output: Displays the rotated image in a window named 'Rotated Image'.
img_modify_SHRINK('cat_img.jpg')
Output: Displays the shrunk image in a window named 'Shrinked Image'.
img_modify_ENLARGE('cat_img.jpg')
Output: Displays the enlarged image in a window named 'Enlarged Image'.
img_modify_CROP('park_img.jpg')
Output: Displays the cropped portion of the image in a window named 'Cropped Image'.
img_modify_SHEAR_X('lady_img.jpg')
Output: Displays the sheared image in a window named 'Sheared X-axis'.
img_modify_SHEAR_Y('lady_img.jpg')
Output: Displays the sheared image in a window named 'Sheared Y-axis'.
img_modify_BLUR_2DKconv('lady_img.jpg')
Output: Displays the blurred image in a window named 'Kernel Blur'.
img_modify_BLUR_Avg('lady_img.jpg')
Output: Displays the blurred image in a window named 'Average Blur'.
img_modify_BLUR_Gaus('lady_img.jpg')
Output: Displays the blurred image in a window named 'Gaussian Blur'.
img_modify_BLUR_Mead('lady_img.jpg')
Output: Displays the blurred image in a window named 'Median Blur'.
img_modify_BLUR_Bilat('lady_img.jpg')
Output: Displays the blurred image in a window named 'Bilateral Blur'.
img_split_COLORSPACES_RGB('color_img.jpg')
Output: Displays the original, Blue, Green, and Red channels of the image sequentially.
img_modify_MASK_CIRCLE('cat_img.jpg')
Output: Displays the masked image with a circular mask applied.
img_modify_BLEND_ALPHABLEND('park_img.jpg', 'lady_img.jpg')
Output: Displays the alpha blended image of the two provided images.
img_show_PLOT_GRAPH_COLOR_HISTOGRAM('park_img.jpg')
Output: Displays the color histogram plot of the image.
img_representated_BITWISE_AND('Bit1_img.jpg', 'Bit2_img.jpg')
Output: Displays the result of the bitwise AND operation on the two images.
img_representated_BITWISE_OR()
Output: Displays the result of the bitwise OR operation on the two images.
img_representated_BITWISE_XOR()
Output: Displays the result of the bitwise XOR operation on the two images.
img_representated_BITWISE_NOT()
Output: Displays the result of the bitwise NOT operation on the provided image.
LittleDogAI, integrated into the LittleDog package, provides a powerful tool for automating coding tasks through AI-driven code generation. Whether you're a developer looking to speed up your workflow or a data scientist handling complex data, LittleDogAI offers a user-friendly interface that makes programming more accessible.